[Haskell-beginners] Monad and bind operator interpretation
Raja
rajasharan at gmail.com
Mon Dec 14 17:49:12 UTC 2015
The type signature of bind (>>=) is as follows:
(>>=) :: m a -> (a -> m b) -> m b
One interpretation of this could be as follows:
bind takes two parameters (m a & f) and returns m b (the same type returned
by f)
So extending this interpretation - can I swap the two parameters (?)
Now my new hypothetical interpretation becomes:
(>>=) :: (a -> m b) -> m a -> m b
If i further add parens:
(>>=) (a -> m b) -> (m a -> m b)
This allows me to slightly tweak my interpretation:
bind takes one param f (of type a -> m b) and returns another param f (of
type m a -> m b)
This feels like a more intuitive way to think about Monads - am I on the
right track?
(not that I want to switch the params permanently - just trying to get a
feel for monads)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151214/6dea19fa/attachment.html>
More information about the Beginners
mailing list