On 17/05/07, Chad Scherrer <[EMAIL PROTECTED]> 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, [EMAIL PROTECTED]
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to