|
|
|
|
|
by rane
3923 days ago
|
|
> Monads take care of a very common computation pattern: wrapping and unwrapping data from a container to do stuff with it. Isn't this what Functor does with `fmap`, not Monad? Even if Monad did not exist and you only had Functor and Applicative, you'd be able to compose `pure` and `fmap` to get the same effect as bind, right? |
|
Look at the specific type signatures:
So yes, monads are not unique in doing wrapping and unwrapping data to use with functions--all functors do this--but all monads are also functors, and also applicative functors, so they do everything the other two do, and more. You can't get at anything like bind using just fmap, ap, and pure/unit. But you can write fmap and ap merely in terms of bind and unit.