-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Support Fantasy Land / Custom Types #2406
Comments
Thanks @JAForbes! Lodash and Underscore used to dispatch to methods here and there. Over time that was pulled. I can see the benefits for sure. It can also introduce accidental dispatching since it's just duck typing. I dig giving devs options though, and I'm curious if lodash/fp could implement it in a configurable way. We'll keep an eye on the popularity of the request. Related to #527. |
Accidental duck typing is theoretically precluded by the fantasy land specification, no? By opting in to APIs that explicitly conform to the spec, the user should be able to isolate any such accidents — and by deferring to the spec, any implementation I think this should be developed as a persistent fork with the aim of replacing / providing a 'stronger' flavour of the current FP branch. |
It's worth noting that Fantasy Land might move to prefixing its functions (fantasyland/fantasy-land#122), to reduce the chances of ducktyping clashes. |
@jdalton The Fantasy Land spec now prefixes all function names. So name collisions are no longer an issue when implementing the specification. |
How many more votes do we need? |
Voting is used as an indicator to see what features folks are interested in. There is no magic number that will force me to implement something. I use this metric to make better informed API decisions. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Thank you everyone for their hard work on this project and lodash/fp. Anything that encourages composition is a huge win for the JS ecosystem.
I'm proposing that Lodash supports dispatch to methods on custom types. This is the number one feature I miss when using lodash/fp in place of Ramda.
An example: say I am using a Bluebird promise that has the methods
filter
,reduce
andmap
. With Ramda I can useR.filter
,R.reduce
andR.map
to dispatch to these methods on the Promise.This dispatch allows you to write one function that can traverse multiple data types. You could just as easily pass in a fantasy land compatible stream like most.js or flyd. Or a Future, Task, Maybe, Either etc. And most importantly it would support any type that the user may want to develop within their own code base.
Note that above we don't need to concern ourselves with chaining
.then
calls. We have abstracted away the specifics of the underlying type. And now the functionf
(from above) would work equally well on an array, or a hundred other types.Lodash is such an important part of the JS ecosystem, I would see supporting this functionality as both extremely useful and also a vote of confidence in composition.
The text was updated successfully, but these errors were encountered: