[Haskell-cafe] Re: Monads and Functions sequence and sequence_
Bardur Arantsson
spam at scientician.net
Sat Oct 30 01:12:36 EDT 2010
On 2010-10-30 07:07, Mark Spezzano wrote:
> Hi,
>
> Can somebody please explain exactly how the monad functions "sequence" and "sequence_" are meant to work?
>
> I have almost every Haskell textbook, but there's surprisingly little information in them about the two functions.
>
> From what I can gather, "sequence" and "sequence_" behave differently depending on the types of the Monads that they are processing. Is this correct? Some concrete examples would be really helpful.
>
sequence [m1,m2,m3,m4,...] = do
x1 <- m1
x2 <- m2
x3 <- m3
x4 <- m4
...
return [x1,x2,x3,x4,...]
sequence_ [m1,m2,m3,m4,...] = do
m1
m2
m3
m4
...
return ()
Cheers,
More information about the Haskell-Cafe
mailing list