We have seen a close connection between composition of world remaking functions and the (>>) combinator. In Haskell we write
instead of
but the underlying thought process isn't so very different.
Function composition is associative. That is for type compatible functions f, g, and h
The . operator is enough like that the (>>) and (>>=) combinators that we would like the latter to be associative too. Since (>>=) is the more important, we want to assert something like
to be true. Of course, it is not even syntactically correct: f must be a monad creating function on the left side of the == but a monadic object on the right side.
We can fix this by making f into a monadic object. All it takes is to evaluate f on an argument x. It is easy to find an appropriate x because for any f
Keeping this in mind and realizing that g has nothing to do with that x we can write an associativity axiom for (>>=) this way
Making use of the fact (>>=) binds from the left and letting m represent an arbitrary monadic object rather than an arbitrary monad, this axiom is usually written
Using the normal definition of (>>) it is possible to prove from this axiom that, for any three type compatible monadic objects, mon1, mon2, and mon3
We will take this similarity with function composition a bit further in Section XII.