Wednesday, January 2, 2008

Haskell: Difference between "<-" left arrow and 'let' expressions

The syntax left arrow denoted by "<-", allows you to bind a variable from the result of an IO computation.

Saizan on freenode does a better job of explaining it...

When asked; What are the main differences between left-arrow and binding a variable with let.

"the <- arrow "extracts" the value from an IO computation, while using let you'd just define another name for the computation as a whole"

"so in let x = getChar, x :: IO Char, but in do x <- getChar; ... x :: Char"

No comments: