[Haskell-cafe] Language semantics

Andrew Coppin andrewcoppin at btinternet.com
Wed Jun 27 16:46:41 EDT 2007

I have a tricky little question...

Suppose I write a function like this:

  foo pattern1
    | gard1 = ...
    | gard2 = ...
  foo pattern2
    | gard3 = ...
    | gard4 = ...

According to one tutorial I read, if pattern1 matches, pattern2 will 
never be tried, even if both guard1 and guard2 fail.

And according to another tutorial I read, if pattern1 matches but all 
guards fail, pattern2 *will* be tried.

Can somebody comfirm which one is actually correct?

More information about the Haskell-Cafe mailing list