sanctuary-js / sanctuary

:see_no_evil: Refuge from unsafe JavaScript
https://sanctuary.js.org
MIT License
3.03k stars 94 forks source link

lte in Ramda vs Sanctuary #549

Closed jgranduel closed 6 years ago

jgranduel commented 6 years ago

Hi,

back to sanctuary after a long while, I've been warming up... Is there an incompatibility here with lte ?

> R.lte(1) (2)
true
> S.lte(1) (2)
false
> S.filter( S.lte(2), [1, 2, 3])
[ 1, 2 ]
> R.filter( R.lte(2), [1, 2, 3])
[ 2, 3 ]

or

> S.filter(S.lte("b"), ["a", "b", "c"])
[ 'a', 'b' ]
> R.filter(R.lte("b"), ["a", "b", "c"])
[ 'b', 'c' ]

In Ramda to Sanctuary, R.lte(x, y) and S.lte(x, y) should be equivalent.

Thanks

davidchambers commented 6 years ago

S.lte and friends take their arguments in the order most natural for partial application:

lte :: Ord a => a -> (a -> Boolean)

Returns true iff the second argument is less than or equal to the first according to Z.lte. The arguments must be provided one at a time.

Sanctuary:

> S.filter (S.gte (0)) ([-27, 8, 25, -54, 25, 41])
[8, 25, 25, 41]

Ramda:

> R.filter (R.gte (R.__, 0)) ([-27, 8, 25, -54, 25, 41])
[8, 25, 25, 41]

I hope this makes the difference clear. :)

Bradcomp commented 6 years ago

It definitely looks like the wiki page is out of date @jgranduel, thanks for bringing attention to that. Would you be interested in updating it?

jgranduel commented 6 years ago

Perfect!

jgranduel commented 6 years ago

@Bradcomp sorry I hadn't seen your comment before closing the issue. Unfortunately, I'm by far not good enough to dare comment on a very useful wiki page :(