Re: [Haskell-cafe] Non-Overlapping Patterns

2008-05-05 Thread Jules Bean
PR Stanley wrote: 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 construc

Re: [Haskell-cafe] Non-Overlapping Patterns

2008-05-05 Thread Andrew Coppin
PR Stanley wrote: To put it another way, why doesn't the interpreter identify the more specific cases and put them before the general ones. I'm guessing because determining which equation is the "most general" is equivilent to the Halting Problem in the general case. (Notice that Mathematica

[Haskell-cafe] Non-Overlapping Patterns

2008-05-05 Thread PR Stanley
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 equ