>>=
has type m a -> (a -> m b) -> m b
Suppose ma :: m a
and f :: a -> m b
.
What is the purpose of >>= :: m a -> (a -> m b) -> m b
more about:
- either being able to implicitly unpack
ma :: m a
toa
so thatf :: a -> m b
can apply to it? Or being able to handle different cases depending on
ma :: m a
? Many implementations of>>=
check argumentma
to see ifma
satisfies some condition. If yes, thena <- ma; f a
. If no, then do something else withma
, sayg ma
, whereg :: m a -> m b
. Is it correct that a more specific and still equivalent version of>>=
would have a typem a -> (a ->m b) -> (... -> m b) -> m b
, where... -> m b
is the type for the third argument likeg
above? If yes, what is type...
? Shall it bem a
? It might not bea
, correct?Or both?
Thanks.