These are chat archives for ramda/ramda

4th
Dec 2014
Jethro Larson
@jethrolarson
Dec 04 2014 00:02
Yeah, I saw that. I guess the tricky bit is simple examples don't show why it's good and complex ones are hard to follow.
Scott Sauyet
@CrossEye
Dec 04 2014 00:07
chain is equivalent to bind, >>= in Haskell, flatMap in some languages, I believe.
Scott Sauyet
@CrossEye
Dec 04 2014 00:28
This is the sort of thing that you might use lenses for:
var mgrSalary = lens(
    function(team) {return team.manager.salary;},
    function(team, newSalary) {team.manager.salary = newSalary;}
);
var team = {/* ... ,*/ manager: {name: "Edie", salary: 132000 /*, ... */};
mgrSalary(team); //=> 132000
mgrSalary.set(team, 141000); 
mgrSalary.mod(add10percent, team);
// team = {/* ... ,*/ manager: {name: "Edie", salary: 155100 /*, ... */};
Jethro Larson
@jethrolarson
Dec 04 2014 00:30
So it's basically using a function to hold a reference...
looks like we use .map instead of .mod btw
Scott Sauyet
@CrossEye
Dec 04 2014 00:31
Not a specific reference. You can pass in any object with the same structure.
Michael Hurley
@buzzdecafe
Dec 04 2014 13:26
team.manager.salary = newSalary; mutating the object @CrossEye ! for shame!
Raine Virta
@raine
Dec 04 2014 15:34
do you guys mostly use ramda functions through a variable (e.g. R.map(foo)) or do you extend global with ramda functions?
ramda was on HN recently and the global extend thing was mentioned
Michael Hurley
@buzzdecafe
Dec 04 2014 15:42
i mostly keep the R namespace
but i do like the cleanliness of using the names on the global scope
Scott Sauyet
@CrossEye
Dec 04 2014 17:04
I like to extend global with it when working on small projects. I probably wouldn't on larger projects.
Jethro Larson
@jethrolarson
Dec 04 2014 19:23
I mostly use ramda with coffeescript and I do destructuring assignment to pick the methods I need
{filter, map, createMapEntry} = require 'ramda'
Scott Sauyet
@CrossEye
Dec 04 2014 19:51
When working inside larger modules where I don't want to use it globally, but where I still don't have access to destructuring (i.e. client-side), I often do the closest I can to it via
(function(R) {
    var filter = R.filter, map = R.map, createMapEntry = R.createMapEntry;
    //...
}(ramda));
Jethro Larson
@jethrolarson
Dec 04 2014 19:54
I was going to partially apply curryN, am I now officially insane?
Scott Sauyet
@CrossEye
Dec 04 2014 19:54
Getting close!
Jethro Larson
@jethrolarson
Dec 04 2014 19:56
it doesn't look like curryN is auto curried, is that an oversight or am I actually insane?
Michael Hurley
@buzzdecafe
Dec 04 2014 19:58
not insane. that looks like a defect to me
should be able to c2 = curryN(2) then whip up as many arity-2 functions as you like
Scott Sauyet
@CrossEye
Dec 04 2014 20:08
The trouble is that the internal curry2 and curry3 are not public. I tried to reimplement curryN in a way that called these ones when appropriate; I can't recall why it failed, but it was something fundamental. @megawac pointed out that there were several reasons not to expose these two functions. The one I remember was that they lost the this context. I can't remember others, although I know there was at least one more.
We should probably curry curryN; it just feels so incestuous.
Jethro Larson
@jethrolarson
Dec 04 2014 20:10
I guess the fix is just:
var curryN = R.curryN = _curry2(function curryN(length, fn) {
Michael Hurley
@buzzdecafe
Dec 04 2014 20:11
@jethrolarson exactly my thinking. i opened an issue for this. i'll fix it unless you wanna
ramda/ramda#642
Jethro Larson
@jethrolarson
Dec 04 2014 20:13
I'll do it for fun
Michael Hurley
@buzzdecafe
Dec 04 2014 20:20
cool thx.
Jethro Larson
@jethrolarson
Dec 04 2014 20:33
Curry2 and curry3 will probably account for 95% of all the times I'll use curryN.
Michael Hurley
@buzzdecafe
Dec 04 2014 20:35
agreed, that is why @CrossEye wants to optimize those paths
Jethro Larson
@jethrolarson
Dec 04 2014 20:44
@CrossEye I saw a presentation you created last year that showed use(fn).over(fn2, fn3) what's the equivalent in the current api?
Michael Hurley
@buzzdecafe
Dec 04 2014 20:46
useWith(fn, fn2, fn3)
Raine Virta
@raine
Dec 04 2014 20:47
when you havevar findByName = compose(find, propEq('name')); is it only possible to use it with two function calls i.e. findByName('foo')(users) instead of findByName('foo', users)?
Michael Hurley
@buzzdecafe
Dec 04 2014 20:48
i think you would have to curry(compose(...))
the problem is if the user puts a variadic function at the right side of the composition. how do we know?
Raine Virta
@raine
Dec 04 2014 21:14
yeah, I see.