[Haskell-beginners] Monad operators: multiple parameters

Mats Rauhala mats.rauhala at gmail.com
Tue Jun 7 14:54:05 CEST 2011


On 04:30 Tue 07 Jun     , Christopher Howard wrote:
> In a reply to an earlier question, someone told me that "do" expressions
> are simply syntactic sugar that expand to expressions with the >> and
> >>= operators. I was trying to understand this (and the Monad class) better.
> 
> I see in my own experiments that this...
> 
> main = do ln1 <- getLine
>           putStrLn ln1
> 
> translates to this:
> 
> main = getLine >>= \ln1 -> putStrLn ln1
> 
> However, what does this translate to?:
> 
> main = do ln1 <- getLine
>           ln2 <- getLine
>           putStrLn (ln1 ++ ln2)

It translates to:

main = getLine >>= \ln1 -> getLine >>= \ln2 -> putStrLn (ln1 ++ ln2)

-- 
Mats Rauhala
MasseR
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110607/9933fba8/attachment.pgp>


More information about the Beginners mailing list