[Haskell-cafe] Newbie : What does the sequence function make?

Benjamin Franksen benjamin.franksen at bessy.de
Mon May 2 14:45:39 EDT 2005

On Monday 02 May 2005 19:42, mandziy at web.de wrote:
> Please,can anyone explain it to me?

  sequence :: Monad m => [m a] -> m [a]
  Evaluate each action in the sequence from left to right, and collect the 

Another way to explain what sequence does is the following implementation, 
which I find a bit easier to understand for the beginner than the one given 
in http://www.haskell.org/onlinelibrary/standard-prelude.html :

sequence [] = []
sequence m:ms = do
  x <- m
  xs <- sequence ms
  return (x:xs)


More information about the Haskell-Cafe mailing list