These are chat archives for ramda/ramda

26th
Feb 2015
David Chambers
@davidchambers
Feb 26 2015 00:21
@megawac, I like it.
Graeme Yeates
@megawac
Feb 26 2015 01:06
@davidchambers what name say you now
you mentioned collect vs restParams last time - I'm not sure how appropriate collect is
David Chambers
@davidchambers
Feb 26 2015 01:31
I still like collect and gather but restParams might be better. If we go with that, though, we should change nthArg to nthParam to match (or name the new function restArgs).
Graeme Yeates
@megawac
Feb 26 2015 01:38
yeah, I'm having second thoughts on its usefulness in ramda actually
mainly if preserving artity/autocurrying will be a requirement
Scott Sauyet
@CrossEye
Feb 26 2015 02:36
Regarding or, ok, I'll probably be buried in something else most of the weekend, but I'll try to take a look. We actually had that at one point, with or/and/not as well as orFn/andFn/notFn, but they didn't seem to be very useful, and we repurposed the simpler names for the function-consuming ones. I haven't felt the lack since, although there certainly is an argument to be made for them.
Neither bindWith or callWith manages to stick with our *With conventions either, I'm afraid, although bindWith is pretty good to my mind.
Scott Sauyet
@CrossEye
Feb 26 2015 02:47
@megawac: any test cases or docs on expected usage? I'm also not sure how it would fit in.
Graeme Yeates
@megawac
Feb 26 2015 02:48
Look at r.call for an example
There's plenty of other cases
Or think pick, where props are strings
Ludwig Magnusson
@TheLudd
Feb 26 2015 12:16
I have a question about the lift function. Is liftN(2) supposed to be the same as liftA2 that I have come across in talks about FP? Or is liftA[n] a special version of the lift function? DrBoolean has examples of liftA2 and liftA3 here https://github.com/DrBoolean/pointfree-fantasy/blob/master/pointfree.js#L47
Hardy Jones
@joneshf
Feb 26 2015 14:41
@TheLudd Yes to the first, the other way around to the second
The only reason liftAn is called liftAn is because Applicative wasn't discovered until recently, and theHaskellhierarchy was built before that. Ideally there'd be noliftAnorliftMnand there would only beliftn`.
but yes, lift is a special version of liftn, where n = 1.
lift = map fwiw
oh wait!
I see ramda's lift takes a function with an arbitrary number of arguments
In that case, yes to both of your questions. :smile:
Ludwig Magnusson
@TheLudd
Feb 26 2015 14:49
ok =)
The reason I was confused was because ramdas lift is not fully curriable. You have to call it with length an function in one go, and then the types in the next one
So is liftA short for "lift applicative"?
Hardy Jones
@joneshf
Feb 26 2015 14:52
something like that
yeah, I'm not sure how the currying stuff works in ramda
Raine Virta
@raine
Feb 26 2015 17:59
today I was trying to come up with an elegant solution for mapping a list of objects in a property of an object two levels deep
with lodash. couldn't come up with anything nice, the api is clunky
Raine Virta
@raine
Feb 26 2015 19:24
is Maybe in ramda-fantasy usable?
Raine Virta
@raine
Feb 26 2015 19:32
going to check out sanctuary
Hardy Jones
@joneshf
Feb 26 2015 20:04
Just had a try with lodash, that is pretty bad
Danny Fritz
@dannyfritz
Feb 26 2015 20:12
@raine maybe i can try with lodash. what do you mean exactly? {{[{},{}]}} ?
Hardy Jones
@joneshf
Feb 26 2015 20:24

I assume you meant something like this:

var foo = {
  bar: {
    baz: [{x: 1, y: 2}, {x: 0, y: 0}, {x: -1, y: -2}]
  }
};

var objLens = function(p) { return R.lens(R.prop(p), R.assoc(p)); };

var bar = objLens('bar');
var baz = objLens('baz');
var x = objLens('x');
var y = objLens('y');

var foo2 = R.pipe(bar, baz.map(R.map(x.map(R.multiply(3)))))(foo);

gives

{
    "baz": [
        {
            "x": 3,
            "y": 2
        },
        {
            "x": 0,
            "y": 0
        },
        {
            "x": -3,
            "y": -2
        }
    ]
}
except that didn't give back the original thing
hmm
oh
var foo2 = bar.map(baz.map(R.map(x.map(R.multiply(3)))))(foo);
Jethro Larson
@jethrolarson
Feb 26 2015 20:26
_.map(foo.bar.baz, _.compose(_.partial(_.multiply, 3), _.property('x')))
Hardy Jones
@joneshf
Feb 26 2015 20:29
or i guess clean it upwith compose
var foo2 = R.compose(bar.map, baz.map, R.map, x.map)(R.multiply(3))(foo);
or as @jethrolarson did :smile:
Jethro Larson
@jethrolarson
Feb 26 2015 20:30
ha, he renamed 'compose' to 'flowRight" and then talks about "established expectations"
Danny Fritz
@dannyfritz
Feb 26 2015 20:31
there is still a _.compose though
Jethro Larson
@jethrolarson
Feb 26 2015 20:32
Yeah, he's opted to keep aliases
Hardy Jones
@joneshf
Feb 26 2015 20:38
that doesn't work @jethrolarson
ah, theres no multiply
Jethro Larson
@jethrolarson
Feb 26 2015 20:40
Okay I didn't actually test it
Hardy Jones
@joneshf
Feb 26 2015 20:40
:)
Jethro Larson
@jethrolarson
Feb 26 2015 20:42
Surprising that there's no operators given the kitchen sink api, but without the focus on currying they probably seem superfluous.
R.compose(R.map(R.multiply(3)), R.path('foo.bar.baz'))(foo);
Jethro Larson
@jethrolarson
Feb 26 2015 20:48
Is the intent to return a copy of foo with the nesting object changed, or to just get the sub array out but mapped?
Hardy Jones
@joneshf
Feb 26 2015 20:49
I can only assume the former, the latter isn't too hard.
Jethro Larson
@jethrolarson
Feb 26 2015 21:39
Can you compose the lenses themselves in some way then map it once? I tried googling about it but results were impenetrable.
I thought maybe R.commute was relevant, but I don't really understand it.
Hardy Jones
@joneshf
Feb 26 2015 21:50
for those kinds of lenses no
those are Costate Comonad Coalgebras, which don't compose easily, least of all in js
van Laarhoven lenses do though
because vL lenses are just functions
well, I take that back
you can compose cococo's
its just not so easy
Jethro Larson
@jethrolarson
Feb 26 2015 21:56
@_@
Hardy Jones
@joneshf
Feb 26 2015 21:59
okay, forget all that
the answer is yes
:)
better?
I'm sure kmett has some explanation of how to compose them
Nate Wildermuth
@wildermuthn
Feb 26 2015 22:13
Does ramda have a way to use Maybe, Either, etc?
Jethro Larson
@jethrolarson
Feb 26 2015 22:16
don't see why that wouldn't work equally well
Michael Hurley
@buzzdecafe
Feb 26 2015 23:21
yes, you should be able to use and fantasyland compat lib with ramda (with some limitations)
you can use them in a pointfree fashion, since ramda will dispatch on an object in list position
e.g.
map(add(1), Maybe.of(10)); //=> Just(11)
i reckon that works better than ramda-fantasy atm
but you ought to be able to use either one