I\'ve always enjoyed the following intuitive explanation of a monad\'s power relative to a functor: a monad can change shape; a functor cannot.
For example: length
Monad
's operations can "change the shape" of values to the extent that the >>=
function replaces leaf nodes in the "tree" that is the original value with a new substructure derived from the node's value (for a suitably general notion of "tree" - in the list case, the "tree" is associative).
In your list example what is happening is that each number (leaf) is being replaced by the new list that results when g
is applied to that number. The overall structure of the original list still can be seen if you know what you're looking for; the results of g
are still there in order, they've just been smashed together so you can't tell where one ends and the next begins unless you already know.
A more enlightening point of view may be to consider fmap
and join
instead of >>=
. Together with return
, either way gives an equivalent definition of a monad. In the fmap
/join
view, though, what is happening here is more clear. Continuing with your list example, first g
is fmap
ped over the list yielding [[1],[],[3]]
. Then that list is join
ed, which for list is just concat
.