Haskell Monad bind operator confusion

You are not making a mistake. The key idea to understand here is currying – that a Haskell function of two arguments can be seen in two ways. The first is as simply a function of two arguments. If you have, for example, (+), this is usually seen as taking two arguments and adding them. The other way to see it is as a addition machine producer. (+) is a function that takes a number, say x, and makes a function that will add x.

(+) x = \y -> x + y
(+) x y = (\y -> x + y) y = x + y

When dealing with monads, sometimes it is probably better, as ephemient mentioned above, to think of =<<, the flipped version of >>=. There are two ways to look at this:

(=<<) :: (a -> m b) -> m a -> m b

which is a function of two arguments, and

(=<<) :: (a -> m b) -> (m a -> m b)

which transforms the input function to an easily composed version as the article mentioned. These are equivalent just like (+) as I explained before.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)