These are chat archives for ramda/ramda

30th
Jan 2017
Vesa Karvonen
@polytypic
Jan 30 2017 08:09
:point_up: January 18, 2017 12:30 PM Well, if you've been following partial.lenses, it does seem possible to design & implement lenses in JS so that performance when using lenses on simple path-like operations is on par with the individual path operations, including prop, assoc, dissoc, nth, update, remove, path, assocPath, and dissocPath. The way partial.lenses does it is by essentially specialising the lens representation (allowing path arrays as lenses) and the implementation to deal with those cases. I wouldn't say it is pretty internally, but I would argue (and have argued) that it is preferable to optimize a library so that one doesn't have to worry about those same issues elsewhere.
partial.lenses also uses a different and more limited (and for that reason significantly faster) currying implementation, that doesn't support placeholders or variadic arguments, but does facilitate staging (unlike Ramda's currying). According to my tests, currying in JS is a major performance killer, unfortunately.
Ryan Zeigler
@rzeigler
Jan 30 2017 14:12
@polytypic what exactly is staging?
Stefan Rimaila
@stuf
Jan 30 2017 14:31
To my understanding, staged functions (generally) work a bit like curried functions, but with the added benefit of allowing you to perform computation on the arguments that are known to the function.
Ryan Zeigler
@rzeigler
Jan 30 2017 14:33
ah
so if you need to do some complex calculation on an early argument
it is performed upon the early argument application
rather than every time one final argument application
Stefan Rimaila
@stuf
Jan 30 2017 14:34
So considering if you have a staged function f(a, b), calling f(a), means you can do some heavy lifting on a, instead of doing that when it's called with b
Yeah, if I've understood it correctly. Seems like this post has a pretty good explanation on it.
Vesa Karvonen
@polytypic
Jan 30 2017 15:34
@rzeigler Yes, by staging I mean the idea that @stuf pointed you to. Here is an example of a staged function: constAs. Specifically, consider the expression curryN(4, ...). It results in a curried function that takes 4 arguments. However, it actually takes arguments in two stages. It first takes two arguments, performs a bit of computation, and then takes two more arguments. The staging allows one to avoid redoing the computation in the middle. Follow the definitions from here to see how they are using constAs. The staging is also mentioned in the documentation and is shown in the approximate type sig (tooltip of the header link) by means of parentheses (F# uses a similar notation).
Alex Deas
@alex-deas
Jan 30 2017 15:53
@polytypic in what ways are partial.lenses currying more restrictive than Ramda's implementation?
Vesa Karvonen
@polytypic
Jan 30 2017 15:54
There is no support for placeholders.
Also, in general, the curry implementation only supports functions that take a fixed number of arguments. Ramda's curry passes extra arguments (beyond the minimal arity) to the function.
Rick Medina
@rickmed
Jan 30 2017 16:58
@JAForbes why flyd vs others (eg most)?
Irakli Safareli
@safareli
Jan 30 2017 19:46
New version of daggy is coming!
Suggestions/Feedback are more than welcome
puffnfresh/daggy#9
Keith Alexander
@kwijibo
Jan 30 2017 20:17
is passing the name to the constructor to enable better toString and better error messages?
LeonineKing1199
@LeonineKing1199
Jan 30 2017 20:35

Is there a good Ramda-y way of turning:

const x = ['a', 'd', 'g'];
const y = ['b', 'e', 'h'];
const z = ['c', 'f', 'i'];

into: 'abcdefghi'

Irakli Safareli
@safareli
Jan 30 2017 20:41
@kwijibo for better toString
@LeonineKing1199 zipWith
Alex Deas
@alex-deas
Jan 30 2017 20:45
const zippy = zipWith((a, b) => a + b)
compose(join(''), zippy(x), zippy(y))(z)
as @safareli pointed out, zipWith
LeonineKing1199
@LeonineKing1199
Jan 30 2017 20:46
Hmm.. Those are multi-pass implementations, right?
LeonineKing1199
@LeonineKing1199
Jan 30 2017 20:49
Isn't that also a multi-pass implementation?
It looks like 3 ap calls
Aldwin Vlasblom
@Avaq
Jan 30 2017 20:49
@ram-bot
const x = ['a', 'd', 'g'];
const y = ['b', 'e', 'h'];
const z = ['c', 'f', 'i'];
compose(join(''), unnest, transpose, unapply(identity))
(x, y, z)
ram-bot
@ram-bot
Jan 30 2017 20:49
'abcdefghi'
Aldwin Vlasblom
@Avaq
Jan 30 2017 20:50
You can leave out unapply(identity) and just pass [x, y, z] into the function instead.
LeonineKing1199
@LeonineKing1199
Jan 30 2017 20:50
Interesting.
Alright, well, thanks, guys!
I got all that I needed