These are chat archives for ramda/ramda

30th
Jul 2017
Philipp Wille
@Yord
Jul 30 2017 07:39
@Sten-H I wasn't aware of this, but looking at the source code (https://github.com/ramda/ramda/blob/master/src/converge.js#L37), I think this is due to the N of curryN in line 37 of converge:
N is computed in reduce(max, 0, pluck('length', fns))
James
@aretecode
Jul 30 2017 07:40
I was reading the source code the other day too and wondering
Philipp Wille
@Yord
Jul 30 2017 07:40
which is 3 in your case (the arity of assoc). So the converge function does still wait on more input. You can circumvent this by redefining prop and assoc:
const prop2 = a => b => prop(a, b)
const assoc2 = a => b => c => assoc(a, b, c)
const lensProp2 = converge(lens, [prop2, assoc2])('x')

view(x, o)
now prop2 and assoc2 have an arity of 1 and converge works as expected
James
@aretecode
Jul 30 2017 07:42
  1. why such an expensive chain of operations to just get length of 2 fns
  2. why does converge only accept 2 when it is an array argument?
Philipp Wille
@Yord
Jul 30 2017 07:47
@aretecode but converge does accept an arbitraty number of arguments?
const toList = (a, b, c, d) => ([a, b, c, d])
converge(toList, [add(1), add(2), add(3), add(4)])(0)
James
@aretecode
Jul 30 2017 07:48
hm...
Philipp Wille
@Yord
Jul 30 2017 07:49
And it seems converge assumes all functions to be resolved before being combined. This is why it needs to get the max length from the list I guess.
(if it does make this assumption, this is new to me, too)
(but then, this is the first time I had a look at the source. Maybe someone else with more knowledge can chime in here :))
James
@aretecode
Jul 30 2017 07:52
hm
seems so...
must have read it wrong the other day, sheesh
Philipp Wille
@Yord
Jul 30 2017 08:02
@Sten-H Sorry about the incomplete code sample earlier. I have corrected it:
const prop2 = nAry(1, prop)
const assoc2 = nAry(1, assoc)
const lensProp2 = converge(lens, [prop2, assoc2])

const x = lensProp2('x')
const state = { x: 1 }

view(x, state)
set(x, 2, state)
over(x, dec, state)
Sten-H
@Sten-H
Jul 30 2017 21:47
@Yord Aha I get it! Thanks so much for taking the time to explain this :)
Jason Shin
@JasonShin
Jul 30 2017 23:57
Hey guys
I really want to introduce ramda-fantasy to my current project at work
mainly because of Future
We are currently using lodash/fp but it doesn't have compose like in Ramda/compose
Should I introduce ramda fantasy?
What do you think?