let-where difference

Tomasz Zielonka t.zielonka at students.mimuw.edu.pl
Mon Dec 22 16:29:23 EST 2003


On Mon, Dec 22, 2003 at 07:15:32AM -0800, Hal Daume III wrote:
> Let is part of an expression, whereas where is part of a declaration.  
> Your first program should be rejected, since lists can only be made up of 
> expressions.  That is, the 'where' in example 1 *must* come after the 
> entire expression [ 1, 2, ... ] so that it can be part of the declaration 
> of f.  OTOH, the let/in in example 2 is fine in situ, because it is 
> part of an epxression, which is allowed for let/in constructs.

You can introduce declaration context in expressions using 'let',
for example:

  f = [ 1,
	2,
	(let x = a+b
	       where a = 1
		     b = 2
	 in x
	)
      ]

Of course it is quite pointless, because then you have both 'let' and
'where'.

Best regards,
Tom

-- 
.signature: Too many levels of symbolic links


More information about the Haskell mailing list