giogonzo / fp-ts-ramda

Ramda functions reimplemented in fp-ts
https://giogonzo.github.io/fp-ts-ramda/
MIT License
138 stars 9 forks source link

allPass #22

Closed kightlingerh closed 4 years ago

kightlingerh commented 4 years ago

Here is an initial shot at an allPass implementation. There are two changes compared to the ramda version:

1) As you mentioned in the issue, this version of allPass does not return a a curried function whose arity matches that of the highest-arity predicate, it only returns a curried unary function.

2) The ramda version of allPass doesn't allow you to call it in an uncurried manner, you have to always supply the array of predicates and then the value. This version allows either and is non-breaking. I would be fine making it exactly the same if that is what you preferred.

I also added a performance test which shows this implementation is ~9x faster than ramda's version (600,654 vs. 5,263,519 ops/sec on my machine). Just for comparison sake, using the built in every method achieved roughly 30 million ops / sec.

giogonzo commented 4 years ago

Hey @kightlingerh thanks for the PR

The ramda version of allPass doesn't allow you to call it in an uncurried manner

Weird, possibly this is this just an issue with ramda typings?

I also added a performance test

Great! Good perfs is definitely a nice to have but the main purpose of this repo is showing fp-ts alternatives to people coming from ramda. So even if the "native" version is faster, I think we are good to go

I'll take a look at the pr soon!

kightlingerh commented 4 years ago

Sweet!

The ramda version of allPass doesn't allow you to call it in an uncurried manner

It looks to me like this is the actual implementation and not just an issue with the typings. Not sure why they have it as such, it seems like a clear deviation from other functions.