On 19/05/07, Andrew Coppin <[EMAIL PROTECTED]> wrote:
Um... why doesn't this work?
my_fn x = do
if x < 0
then do
let y = 5
return ()
else do
let y = 8
return ()
print y
(Error: "y" is not in scope.)
let-blocks only scope over the do-block they're contained in. Here y
is out of scope once you leave the inner do-block. The solution is to
do something like the following:
do
let y = if x < 0 then 5 else 8
print y
--
-David House, [EMAIL PROTECTED]
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe