[Haskell-cafe] Small syntax question

Ketil Malde ketil.malde at bccs.uib.no
Mon Feb 13 09:27:04 EST 2006


Maurício <briqueabraque at yahoo.com> writes:

>    Why isn't this one [valid code]?

> module Main where
> main = do {
> 	let a = 3;
> 	return ();
> };

My guess is that the compiler is confused about whether you mean

   do let a = 3
          return ()

or (your intended):

   do let a = 3
      return ()

A solution which appears to work with GHCi is:

   do let {a=3}; return ()

(Note that you don't need the enclosing {}s (although everybody seem
to use them), nor the terminating semicolons (they are for statement
separation, not termination - Pascal not C) -- they seem to be
harmless, though.

-k
--  
If I haven't seen further, it is by standing in the footprints of giants



More information about the Haskell-Cafe mailing list