fantasy-land | Specification for interoperability of common algebraic structures in JavaScript | Functional Programming library
kandi X-RAY | fantasy-land Summary
kandi X-RAY | fantasy-land Summary
(aka "Algebraic JavaScript Specification").
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of fantasy-land
fantasy-land Key Features
fantasy-land Examples and Code Snippets
Community Discussions
Trending Discussions on fantasy-land
QUESTION
Recently I have decided to switch from lodash to ramda to play with functional way of composing my logic. I love it! After some extensive digging into FP I have found that's it's not only about handy pure/point free utilities (ramda), but more about complex (at least for me) math abstractions (fantasy-land). I don't get all of it, but Either and Task pattern looks very handy. Problem is that I am not sure how to merge it with ramda utilities. I know about ramda-fantasy, but it's no longer maintained. Ramda-fantasy suggested libraries doesn't work the same way as ramda-fantasy. With all this new information about Monads/Monoids/Functors types I am completely lost.
For example, what the convention for this?
...ANSWER
Answered 2021-Jul-16 at 13:15One way to think about it is to think about types versus functions.
Ramda offers a large collection of utility functions. They operate on arrays, on objects, on functions, on strings, on numbers, etc. But they also operate on user-defined types. So in your example, R.map
operates on anything which matches the Functor specification. If the implementation of Either
you use matches that specification, then Ramda's map
will operate on it.
But Ramda does not supply types. It works with the built-in types such as Object, Array, Function, etc. But -- arguably outside Lens
-- it does not supply any types of its own. Libraries such as Folktale provide large collections of types, such as Maybe
, Result
, Validation
, Task
and Future
; more dedicated ones such as Fluture provide powerful versions of one specific type (Future
). All of these types implement the Functor specification. A very incomplete list of such implementations is supplied by FantasyLand.
These two notions, functions on an abstract type and collections of types are complementary. A Ramda function which works on any functor will work on whatever version of Either you use (so long as it matches the specification.) More on this relationship is in this StackOverflow Q+A.
The question compared these two snippets:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fantasy-land
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page