[Haskell-cafe] What is <-

Christopher Done chrisdone at googlemail.com
Sun Aug 8 09:39:38 EDT 2010


In shortyes, "do z <- ..; foo" desugars to "... >>= \z -> foo"

The Haskell Report describes `do' notation in detail:

http://www.haskell.org/onlinereport/exps.html#sect3.14

Real World Haskell describes its uses:

http://book.realworldhaskell.org/read/io.html#io.bind

On 8 August 2010 15:36, michael rice <nowgate at yahoo.com> wrote:

> What is <- ? Couldn't find anything on Hoogle.
>
> 1)  main = do
>       x <- getLine   -- get the value from the IO monad
>       putStrLn $ "You typed: " ++ x
>
> 2)  pythags = do
>       z <- [1..]     --get the value from the List monad?
>       x <- [1..z]
>       y <- [x..z]
>       guard (x^2 + y^2 == z^2)
>       return (x, y, z)
>
>
>
> From: http://en.wikibooks.org/wiki/Haskell/Syntactic_sugar
>
> Do and proc notation
>
>
>                       Sweet                                Unsweet
> Monadic binding  do x <- getLIne                      getLine >>= \x ->
>                     putStrLn $ "You typed: " ++ x     putStrLn $ "You
> typed: " ++ x
>
>
> So, Example 2 desugared becomes...
>
>      [1..] >== \z ->  ?
>
>
>
>
>
> Michael
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100808/e415a801/attachment.html


More information about the Haskell-Cafe mailing list