On Thu, 2007-11-22 at 09:19 +0100, Peter Verswyvelen wrote:
> worksFine =
> if True
> then putStrLn "True"
> else putStrLn "False"
>
> worksNOT = do
> if True
> then putStrLn "True"
> else putStrLn "False"
>
> worksAgain = do
> if True
> then putStrLn "True"
> else putStrLn "False"
>
> Of course the worksFine function returns an IO action, so has
> different behavior, but I mean the indentation is different. Is this
> by design?
>
>
> Also the following is rather strange:
>
> doubleDefError = let x = 1
> x = 2
> in x * x
>
> alsoDoubleDefError = do
> let x = 1
> x = 2
> return (x*x)
>
> doubleDefNOERROR = do
> let x = 1
> let x = 2
> return (x*x)
>
> Now I understand why this is (the second let starts a new invisible
> scope no?), but for newbies, this is all very strange :-)
Now go and read about 'mdo' (recursive 'do' notation) ;)
BTW, don't you get the same behaviour?
foo = let x = 1 in
let x = 2 in
x * x
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe