# = vs ->

**D. Tweed
**
tweed@compsci.bristol.ac.uk

*Wed, 10 Oct 2001 23:20:11 +0100 (BST)*

On Wed, 10 Oct 2001, Mark Carroll wrote:
>* On 10 Oct 2001, Ketil Malde wrote:
*>* (snip)
*>* > function definitions. Perhaps one could have had a syntax like
*>* >
*>* > z a =
*>* > | a == 1 -> 1
*>* > | a == 2 -> 3
*>* >
*>* > instead, as it'd make it more consisten with the case, but I suppose
*>* > there's a reason for it being the way it is. The case statement is an
*>* (snip)
*>*
*>* Ah, yes - it was this 'discrepancy' that was one of the sources of my
*>* confusion, as "a == 1" obviously doesn't 'equal' "1".
*
I think this comes about from history; in the functional languages like
Miranda & Orwell that preceded Haskell an extended version of the function
above would have been written
z a = 1 if a==1
= 2 if a==2
= 3 otherwise
which looks a lot like traditional mathematics and where the equals makes
sense. I'm not sure why anymore but Haskell changed the `if clause after
the value' to `pattern guard | before =', so I agree it now looks as if
it's stating that the pattern guard is equal to the rhs.
___cheers,_dave________________________________________________________
www.cs.bris.ac.uk/~tweed/pi.htm |tweed's law: however many computers
email: tweed@cs.bris.ac.uk | you have, half your time is spent
work tel: (0117) 954-5250 | waiting for compilations to finish.