These are chat archives for ramda/ramda

29th
May 2018
Rocky Madden
@rockymadden
May 29 2018 17:53
@danielo515 and @smeijer I, too, found scenarios in which point free was non-ideal. Particularly at the top level of functions where there was no accompanying inline/enforced signature. I'd have to go figure out what it was composed of and returned in all scenarios to figure out the signature. However, by using sanctuary-def, I've found that I can indeed use point-free by having a solid, and enforced, signatures.
Doing so also really points out when your function signature is non-ideal (e.g. anything variadic is eww, returning two different types in diff scenarios, etc). This does go in hand with the viewpoints of Sanctuary, but I found it quite revealing, generally, how often I was doing weird things by simply forcing myself to write out the signatures.
itaied
@itaied246_gitlab
May 29 2018 18:08
Why doesn't reduce have an implementation without the initValue?
reduce(and, true))([true, true, false])
I cant do reduce(and)([true, true, false])
Rocky Madden
@rockymadden
May 29 2018 18:11
reduce(and, true))([])
In your scenario, if the list is empty it is forcing you to state default case. Otherwise, it would have to return something like undefined. You could write something that does that if you wish for sure.
itaied
@itaied246_gitlab
May 29 2018 18:17
ok, I got it, thanks
Rocky Madden
@rockymadden
May 29 2018 18:17
const reduceUndefined = R.reduce(R.__, undefined, R.__);
Ryan Olson
@ryanolsonx
May 29 2018 18:43
How would I use point-free style with this notIn function? https://goo.gl/cBY5pY
const notIn = R.curry((exclusion, item) => { return R.equals(-1, R.flip(R.indexOf)(exclusion)(item)) })
I tried something like const notIn = R.compose(R.equals(-1), R.flip(R.indexOf)) but that didn't work.
Rocky Madden
@rockymadden
May 29 2018 19:36
notIn :: Array a -> a -> Boolean?
While not directly answering, you can also R.complement(R.contains)
Brad Compton (he/him)
@Bradcomp
May 29 2018 20:33

@ryanolsonx Your implementation would work, but compose doesn't return a curried function. If you wrap it in curryN(2, ...) it will work fine.

@rockymadden you'd want to flip contains, but then it works...

Lastly, in the case of getFiltered you could just use R.difference(list, excluded) to get the answer, but of course that doesn't actually answer your question ;)