[Haskell-cafe] Bad "let..do" syntax
David House
dmhouse at gmail.com
Thu May 17 15:04:13 EDT 2007
On 17/05/07, Chad Scherrer <chad.scherrer at gmail.com> wrote:
> But GHC complains of "Empty 'do' construct".
Because it takes the indented following lines as being new bindings in
the let-block. The trick is to intent them past the 'sum':
let b = sum $ do
y <- [0..x + 1]
return y
Or to bypass layout altogether:
let { b = sum $ do
y <- [0..x + 1]
return y }
(Of course, in this specific case I'd write sum [0..x + 1], but I
guess that this is an example of a general case.)
--
-David House, dmhouse at gmail.com
More information about the Haskell-Cafe
mailing list