3 ms·
"We can see therefore how Monad offers strictly more powerful transformations than Functor. fmap can only transform an individual value “in place”, while >>= ca
by heroku 11y ago
"We can see therefore how Monad offers strictly more powerful transformations than Functor. fmap can only transform an individual value “in place”, while >>= can return an empty list, or a list with more elements than the original. Functor is “structure preserving”, while Monad is “structure transforming”."
So for a list monad
bind = flatMap
fmap = map
is that correct?
Studying FP for quite a while first monad tutorial I come to fully understand finally.
- chriswarbo 11y ago> So for a list monad bind = flatMap fmap = map > is that correct? Yes, although Haskell calls "flatMap" "concatMap". Of course "return" is just "\x -> [x]", AKA "(: [])". Instead of bind (">>="), you can implement Monads using "join" instead. For lists, "join" is simply "concat".