These are chat archives for ramda/ramda

28th
Jul 2015
Scott Sauyet
@CrossEye
Jul 28 2015 01:37
Part of the reason that we don't want idx on things like map is that these functions are meant to be more generic than just array-based versions. But an idx parameter doesn't necessarily have a meaning for a stream or a lazy list, and it definitely doesn't have a meaning for an arbitrary Functor.
Scott Christopher
@scott-christopher
Jul 28 2015 03:11
I have been caught out a number of times by trying to use R.gt(10) rather than R.gt(R.__, 10) as a predicate for some function.
I'm curious to know what people think about flipping the argument order of gt, gte, lt and lte.
I'm personally in two minds about it, because I find myself wanting to do something like the following quite often:
R.filter(R.gt(10), [5, 10, 15, 20]) // currently [5, 10], though expect it to be [15, 20]
On the other hand, when given both arguments I’m not sure the flipped version is as nice.
Scott Sauyet
@CrossEye
Jul 28 2015 03:21
We tried an interesting approach to that in #368, but reverted it very soon (#388) for some very good reasons, and ended up with just the placeholders. This was later expanded to work for all functions, not just binary operators. The trouble with flipping them is that subtract(12, 6); //=> 0.5 or gt(5, 2); //=> false are to most users even more surprising than the current behavior on currying. It's certainly not ideal. For some time we had second versions of these non-commutative operators, subtractFrom, divideBy, but those always felt cheesy, and weren't easy to extend to lt, gte, etc.
I looked for feedback on StackOverflow once and the very interesting answer lead to our quickly aborted attempt.
I agree that I would like some great solution to this. I remember that there is a library that seems designed around this very issue, but I wasn't over-impressed. Trying to remember what it was.
David Chambers
@davidchambers
Jul 28 2015 03:55

https://github.com/algesten/fnuc/blob/master/api.md#arity:

Dual purpose method to check or force function arity.

I find it surprising for one function to serve as both R.length and as the defunct R.arity.
Scott Sauyet
@CrossEye
Jul 28 2015 03:58
Sounds very jQuery-ish
David Chambers
@davidchambers
Jul 28 2015 04:07
Indeed.
Scott Christopher
@scott-christopher
Jul 28 2015 04:07
That’s a great stackoverflow answer.
Martin Algesten
@algesten
Jul 28 2015 18:57
Not over impressed :D
@davidchambers I just committed a fix for that little dual purpose-ness. It's now arity or arityof ... was just a hangover from when I started writing it ;)
David Chambers
@davidchambers
Jul 28 2015 18:59
@algesten, that sounds good!
Martin Algesten
@algesten
Jul 28 2015 19:07
The main differences between Ramda and my little lib is basically that I think it's right to do div(a,b) and div(b)(a). That and I'm less hardcore immutable – my thinking is that javascript is mutable. Whether or not I as a developer chose to mutate is my problem (not the lib). Hence fnuc has set(obj, key, val) as well as get(obj, key) (and merge etc).
Well... those differences, and a huge user base :D
But it's ok. fnuc can continue to be underwhelming. It suits me, @CrossEye ;)
David Chambers
@davidchambers
Jul 28 2015 19:10
It’s good to have variety. I created a spin-off library because Ramda isn’t strict enough for my taste.
Martin Algesten
@algesten
Jul 28 2015 19:14
Oh. Which one?
sanctuary?
David Chambers
@davidchambers
Jul 28 2015 19:14
That’s right.
Martin Algesten
@algesten
Jul 28 2015 19:19
exciting. i just yesterday argued that i don't like typed languages because it's not the type where i slip up (last couple of weeks i've programmed swift/java). sanctuary is kind of going the opposite way of what i was arguing. do you find this style makes you less error prone?
Ludwig Magnusson
@TheLudd
Jul 28 2015 19:20
@davidchambers not strict in what sense?
David Chambers
@davidchambers
Jul 28 2015 19:21
Not strict in two senses:
  • it has unsafe functions such as R.head; and
  • it fails in unspecified ways when given bad input.
@algesten, I make just as many errors, but Sanctuary’s run-time type checking helps me to quickly identify the source of a type mismatch. Once the types line up, I have more confidence that the code will work correctly in all cases because Sanctuary provides replacements for partial functions such as R.head.
Scott Sauyet
@CrossEye
Jul 28 2015 21:27
@algesten: found it interesting, as it offered a consistent solution to a problem that had been bugging me for a long time. But add it was a solution I'd already rejected
For Ramda, and as I didn't are much more to catch my eye, I've never paid it much attention. (I am actually one of the repo watchers, though, as I think it had more potential than most. )
Hate this interface on my phone.
... "and as it didn't have much more to catch my eye"...