I'm having trouble understanding how the iterative behavior of the list monad can be derived from its definition.
instance Monad [] where
m >>= f = concatMap f m
return x = [x]
fail s = []
Discussions I've read seem to pass over the question of how >>= creates a control structure, as shown most clearly with do notation:
allEvenOdds :: Int -> [(Int,Int)]
allEvenOdds n = do
evenValue <- [2,4 .. n]
oddValue <- [1,3 .. n]
return (evenValue,oddValue)
Is this built in to Haskell, the way I assume the IO monad's interface to actual i/o is?