kapolos / pramda

Practical Functional Programming in PHP
MIT License
244 stars 13 forks source link

More functionalities to Pramda #12

Open rsmoorthy opened 8 years ago

rsmoorthy commented 8 years ago

Hello @kapolos,

First of all, thank you very much for this wonderful library Pramda. I have started using it, in one of the core rewrites of a PHP module - in a functional way.

  1. I would like to cover more functions to Pramda, something that is useful to me, which is covered in Ramda 0.21, but not present in current Pramda. Can I submit a pull request with these additions?

They include:

and more.

  1. Do you have plans to include Fantasy Land spec?
kapolos commented 8 years ago

Hey @rsmoorthy!

I'm very glad you've found Pramda useful for your work! :beers:

I would absolutely love pull requests. :+1: Currently the master branch is based on 0.9 but 0.10 is practically ready (apart from some docs) and so I will wrap it up and merge it into master tomorrow.

Regarding the Fantasy Land spec, my thought at the time was to let its implementation for the future. My main concern with it was in regards to documentation. While someone with a background of FP can easily see what each function does, a newcomer to the paradigm won't. As it is, the practical "documentation" for the functions is to look at the source code. In that sense, it was a deliberate decision to have the source code be as readable as possible. Including the Fantasy Land spec will make the code more complex and harder to read (in regards to the newcomer).

So, my idea was to include the spec after we have some reasonable documentation for each function. That said, nothing is written in stone - if the need for it surpases the current disadvantages, why not?

rsmoorthy commented 8 years ago

@kapolos Thanks for your quick response.

I am making those additions (have done only memoize for now). Will submit the pull request, after the other changes is done as well by next weekend or so. Will do that after your merge, in any case.

My main interest with Fantasy Land spec was more for avoiding exceptions, and handling it via Maybe or Either would be more apt - from a pure FP point of view. But I agree with you, that newcomers (including me, when I started) will struggle to understand both on FP and Pramda. Even in the case of Ramda, they have implemented it as a separate library and none of the core Ramda methods would return a Maybe/Either, for ex, to signal errors. So, I concur with you to - keep Pramda, as is - but may be implement Pramda-Fantasy as a separate class.

If there is a way to avoid exceptions, that will be helpful. Or any of the user functions in the pipe line, wants to return an error, it should be easy and elegant to do. Any thoughts?

rtodea commented 7 years ago

@rsmoorthy, @kapolos, any updates?

kapolos commented 7 years ago

@rtodea I've been swamped, sorry. I do want to add more, so hopefully Soon(tm)