[Haskell-cafe] What is <-
bulat.ziganshin at gmail.com
Sun Aug 8 10:34:28 EDT 2010
Sunday, August 8, 2010, 5:36:05 PM, you wrote:
i highly recommend you to read
that is the best introduction into monads i know
and then http://haskell.org/all_about_monads/html/index.html
- comprehensive tutorial about many useful monads
both are mentioned at http://en.wikipedia.org/wiki/Monad_%28functional_programming%29
> 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 -> ?
Bulat mailto:Bulat.Ziganshin at gmail.com
More information about the Haskell-Cafe