[Haskell-cafe] Language semantics

Andrew Coppin andrewcoppin at btinternet.com
Fri Jun 29 14:13:16 EDT 2007

Jon Cast wrote:
> On Wednesday 27 June 2007, Andrew Coppin wrote:
>> Wow, wait a sec - case expressions are allowed to have guards too??
> Yes.  I guess I assumed you knew that, sorry.
> The only syntactic (or semantic) difference between function equations and 
> case expressions (aside from the fact that case expressions require you to 
> tuple up the values you're pattern-matching on) is the fact that case 
> expressions use -> where function bindings use =.  Other than that, the two 
> forms are exactly equivalent.

I knew they were nearly identical. I didn't realise that they *were* 

Hmm, I tried to find out 1 thing and actually found out 2 things! :-D

I wonder what the layout for that is... something like this?

  case foo of
      | guard1 -> ...
      | guard2 -> ...
      | guard3 -> ...
      | guard4 -> ...

Well, I'll have to go try it...

I always thought of guards as being a nice shorthand for if-expressions 
- but if they can affect the order of pattern matching, clearly they are 
more drastically different than I realised. (Generally, I never ever use 

More information about the Haskell-Cafe mailing list