monads
declarativePure functionsInmutablecurryingfunctors
So let’s remember first what’s a functor:
1. It is a wrapper object to contain our data2. had a map function to iterate over its own data3. preserves identity4. can be composable
But functors by themselves aren’t compelling, because they’re not expected to
know how to handle cases with null data.
Ramda's R.compose
, for instance,
will break if a null function reference is passed into it. This isn’t a flaw
in the design; it’s intentional.
-
Functors map functions of one type to another.
-
More-specialized behavior can be found in functional data types called monads.
-
Among other things, monads can streamline error handling in your code,allowing you to write fluent function compositions.
-
What’s their relationship to functors? Monads are the containers that functors “reach into.”