[Haskell-cafe] Non-Overlapping Patterns

PR Stanley prstanley at ntlworld.com
Mon May 5 10:58:53 EDT 2008


Hi
isZero :: Int -> Bool
isZero 0 = True
isZero n | n /= 0 = False

The order in which the above equations appear makes no difference to 
the application of isZero. Does the Haskell interpreter rewrite 
patterns into one single definition using some sort of switch or if 
construct? Why does an equation without a guard have to be placed 
after the more specific cases?To put it another way, why doesn't the 
interpreter identify the more specific cases and put them before the 
general ones.
Cheers
Paul



More information about the Haskell-Cafe mailing list