Original-Via: uk.ac.st-and.cs; Fri, 1 Nov 91 09:37:40 GMT
Brian says there are two distinct problems with n+k patterns,
1) That laws relating * `div` `rem` + - might not hold.
2) A user defined >= might not be strict giving rise to a match
of bottom to a refutable pattern converging.
The second one could be 'solved` by changing the operational semantics of
n+k patterns so that it didn't include the test. I suppose the reason why
it was included was that n+k (usually n+1) patterns are traditionally
associated with primitive recursive definitions of functions over the
natural numbers rather than the integers. But Haskell doesn't have Nat as
a `base` type, (though users could define it --- and then get the benefits of
exactly the pattern match they needed).
I'm not sure if Haskell even has Int as a base type -- or even Bool. Should a
user really be allowed to redefine the operators on these types? The first of
the problems above could possibly be solved by disallowing n+k patterns
from being overloaded and insisting they be of BUILT-IN type Int. Though
come to think of it, Ints don't obey the div,rem,*,+,- laws if an overflow
is involved.
Which leads me to one final comment. Does the Report say anywhere that
an overflow gives rise to an undefined result?
Tony