Phil writes:
> In the absence of convincing answers, I'd rather have as many laws
> as possible, hence my preference for unlifted tuples and products.
Here's another law that I find useful:
If we write
f p = p
where p is some pattern&expression then I expect f to be the identity
function when p matches. E.g.
f (x:xs) = (x:xs)
or
f True = True
behaves that way. Unfortunately it is not true in Haskell.
Counterexamples:
f (n+1) = n+1
(meaning
f x | x >= 1 = n+1 where n=x-1
)
since n+k patterns are defined in terms of >= and -, and there is
absolutely no guarantee that - is the inverse of +.
Another example
f 5 = 5
(meaning
f x | x == fromInteger 5 = fromInteger 5
)
and we don't know what equality means in general so it may fail again.
Will you therefore suggest that we drop n+k patterns and pattern
matching on numeric literals to make more laws hold?
-- Lennart
PS. I agree with Paul, if that wasn't clear.