The expression

    sequence [a,b,c,...]

is roughly equivalent to

    do
        r_a <- a
        r_b <- b
        r_c <- c
        ...
        return [r_a,r_b,r_c,...]

The expression

    sequence_ [a,b,c,...]

is roughly equivalent to

    do
        a
        b
        c
        ...
        return ()

Does that help?

Cheers,
Greg

On 10/29/10 10:07 PM, 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.

Even references to some research papers that explain the rationale behind these 
(and all the other..?) monad functions would be great.

Thanks in advance,


Mark Spezzano
  _______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to