[Haskell-cafe] Bad "let..do" syntax
Chad Scherrer
chad.scherrer at gmail.com
Thu May 17 14:50:56 EDT 2007
I've gotten into a habit of preceding most "do"s in my code with a
"$", and indenting the next line. I kind of like this, since it makes
the indentation more uniform. But it seems to have bitten me now. I'd
like to write something like this
s = sum $ do
x <- [1,2,3]
let b = sum $ do
y <- [0..x + 1]
return y
return (x + b)
But GHC complains of "Empty 'do' construct". It likes the alternative
s' = sum $ do
x <- [1,2,3]
let b = sum $ do y <- [0..x + 1]
return y
return (x + b)
just fine, but that looks horrible to me (ok, "horrible" is a bit
strong, but I don't like it as much).
So I'm wondering, (1) Is this intended to give an error, or is it just
a momentary hiccup, and (2) if others have run into this, is there a
more aesthetic alternative that works?
Thanks,
Chad
More information about the Haskell-Cafe
mailing list