-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flatMap is missing #63
Comments
Thanks for opening the issue and your suggestions. While you explicitly describe your request, it will be much easier for me if you accompany each of them with simple pseudo-code, such as:
In general I am open to implement all of your suggestions, but that will have to wait for Typescript 2.8 to arrive(between 1 and 2 months from now). Then Rambda will switch to Typescript and all of method will be rewritten. During this major change, I will implement all of your suggestions. I hope you do understand and I will wait for the pseudo-codes. |
Why the switch to TypeScript? Surely that will just cut down on the pool of people who could help with the project. I was just looking at switching to this from Ramda, with the view that I would just implement and contribute any methods that I currently use that are currently missing. If you switch to TypeScript then I think I will just have to fork the project which is a shame. |
This is big IF for the change to Typescript as we are still waiting for varadic arguments support. That may happen this year maybe not. When it does, it may lead to rewrite but it could lead just to easier to read/write typings file. |
I can help you with some of these functions, but can you answer some questions first? I have read the
I need |
That is very nice of you to help me out. Here are the answers:
|
Why is there no flatMap operation? It's not only very useful, it's also the bind operation for the list monad, so it's kind of heresy to omit it from a "functional" library ;)
There's a "flatten" in rambda, but because it flattens recursively, one can't simply define flatMap as compose(flatten, map).
So please consider adding a non-recursive shallowFlatten and also 'flatMap' (ideally an optimized one, but one based on map and shallowFlatten would also do).
Also a 'scan' operation (similar to reduce but building a list of the result of each iteration instead of giving just the end-result) would be useful (but far less important as flatMap).
Another useful operation would be somethink like "any" which would only test for 'undefined' and return the first non-undefined result of the iteration. This is useful to return the first successful application of a value to some operation (similar to 'find' but returning an arbitrary value instead of the found element).
The text was updated successfully, but these errors were encountered: