These are chat archives for ramda/ramda

15th
Jul 2017
mpontus
@mpontus
Jul 15 2017 09:39
How can I create a function that accepts a number of arguments and puts them into a structured object?
I.e. (foo, bar) => ({ foo, bar })
Can ramda help make this pattern less repetetive?
James Forbes
@JAForbes
Jul 15 2017 11:02

unapply(zipObject(['foo', 'bar']))

The unapply is only necessary here because foo, bar isn't a list

Saber I.
@icybears
Jul 15 2017 11:04
hi, I'm new to functional programming, and while I was watching some course about FP, the instructor started using ramda, and my question is, when should one use ramda in his app ?
mpontus
@mpontus
Jul 15 2017 11:08
@JAForbes Oh, smart! Thank you.
Kurt Milam
@kurtmilam
Jul 15 2017 11:23
@rainfalldelight wherever it fits and there's not another good, native way to accomplish the same thing in a functional manner.
What kind of app are you building? Do you have any code you can share? Have you used any other libraries like lodash or underscore?
Saber I.
@icybears
Jul 15 2017 11:37
@kurtmilam thank you for your input, I've never used lodash nor underscore, I'm fairly new to web dev and I'm currently learning reactJS and while I was doing so I thought of learning FP too. does it mean that, instead of trying to build your own functions using native api, you can simply use ramda to help you out and leave your code cleaner ? If so then ramda is a great thing. But I'm not sure when to resort to ramda. or maybe always resort to ramda ?
Kurt Milam
@kurtmilam
Jul 15 2017 11:39
@mpontus another option:
const a = 1
const b = 2
const c = 3
const mergeLots = ( ...x ) => mergeAll( x )

mergeLots( {a}, {b}, {c} ) // -> {"a": 1, "b": 2, "c": 3}
mpontus
@mpontus
Jul 15 2017 11:41
@kurtmilam Its an option, thank you!
Kurt Milam
@kurtmilam
Jul 15 2017 11:44
@rainfalldelight Ramda is a toolchest that offers a number of utilities to help you accomplish various common tasks in a functional manner. I use it when I have such a task that I need to accomplish and I find it more trouble to write my own reusable utility to accomplish the task than I do to just use Ramda's.
Starting out, if you really want to get into functional programming, you may find that you're using Ramda very often or even always. As you learn, you should be able to recognize places in your code where native solutions would do just as well as Ramda's. But trying to fit things into a Ramda box can be a good way for someone just getting started with FP to get into the mindset, I think.
Saber I.
@icybears
Jul 15 2017 11:48
@kurtmilam gotcha! thank you for making things clear !
Kurt Milam
@kurtmilam
Jul 15 2017 11:49
It will probably also help if you commit to writing pure functions and not mutating objects/arrays. It's likely you'll run into situations where you're not sure how to accomplish something while sticking to those rules using native tools. This can be a good time to look at the Ramda docs and try to find a utility that will help you solve your problem purely and without mutating.
@rainfalldelight :thumbsup: People here tend to be helpful, so always feel free to ask questions if you're stuck.
Saber I.
@icybears
Jul 15 2017 11:50
sure thing thanks again!
James Forbes
@JAForbes
Jul 15 2017 14:01
@mpontus :+1: