These are chat archives for ramda/ramda

26th
Jun 2015
Asaf
@asaf-romano
Jun 26 2015 16:25
Is it intended that a synchronous throwing method in a pipeP/composeP doesn't result in the generated function returning a to-be-rejected promise?
asaf-romano @asaf-romano prepares an example
Asaf
@asaf-romano
Jun 26 2015 16:31
hrm, I cannot reproduce that in repl
Tobias Pflug
@gilligan
Jun 26 2015 18:28
FYI : marijnh/tern#570
can I get that pointfree somehow ? R.ifElse(g, R.add(1), R.subtract(1)) is of course not quite right
David Chambers
@davidchambers
Jun 26 2015 21:15
@gilligan, I don’t recommend this but here it is:
R.ifElse(g,
         R.pipe(R.nthArg(1), R.inc),
         R.pipe(R.nthArg(1), R.dec))
Tobias Pflug
@gilligan
Jun 26 2015 21:16
ah.. nthArg
but yeah. looks meh
@davidchambers but thanks a lot for making me aware of nthArg ;)
David Chambers
@davidchambers
Jun 26 2015 21:16
No problem!
Tobias Pflug
@gilligan
Jun 26 2015 21:17
and inc/dec - i've skimmed the docs several times but takes time until everything sticks :)
David Chambers
@davidchambers
Jun 26 2015 21:18
Yeah, it takes a while to memorize 200+ functions. There are dozens of Ramda functions I’ve never even used!
Asaf
@asaf-romano
Jun 26 2015 21:18
hrm, is there any way to define a recursive piped/composed function
David Chambers
@davidchambers
Jun 26 2015 21:18
Not without using a thunk.
Asaf
@asaf-romano
Jun 26 2015 21:18
thunk?
David Chambers
@davidchambers
Jun 26 2015 21:19
var f = R.pipe(a, b, c, function(x) { return f(x); });
Asaf
@asaf-romano
Jun 26 2015 21:19
clever
David Chambers
@davidchambers
Jun 26 2015 21:19
A thunk is a function used to delay evaluation.
The problem is we can’t refer to f in the definition of f in a strictly evaluated language, but a thunk allows us to do so.
Asaf
@asaf-romano
Jun 26 2015 21:20
with a lamda, it's almost elegant :)
David Chambers
@davidchambers
Jun 26 2015 21:20
Yep!
Asaf
@asaf-romano
Jun 26 2015 21:23
hrm, In practice, most of the elegance is lost with the branched pipes though (for the exit condition)
too bad!
Asaf
@asaf-romano
Jun 26 2015 21:59
in other news, it's a sign when you import { nap } rather than { map }.