Simon Peyton-Jones wrote:

I agree that if (n+k) patterns go, then so should k patterns.  Both are
overloaded, and that's the root of their complexity.

Personally I think ~ patterns are great, and we are now talking about !
patterns, a kind of dual to ~ patterns.  So at least I think we should
un-couple the two discussions.
I agree that it is sensible to decouple the two discussions, so just add k patterns to n+k patterns.

However, ~ patterns are really currently the most complicated patterns and ! patterns match them in their complexity. Personally I believe that programmers should strive for more laziness, rarely for more strictness. I do not like that you can add ! in lots of places where it doesn't make any difference, e.g.

f [] !x = rhs1
f (y:ys) !x = rhs2

is the same as

f [] !x = rhs1
f (y:ys) x = rhs2


Your motivating example

f2 !x !y | g x = rhs1
           | otherwise = rhs2

I would express as

f2 x y = x `seq` y `seq` if g x then rhs1 else rhs2

Now you will probably counter with a definition where you can fall through the guard to the next equation. In my opinion that just shows how horrible guards are (and I would propose their removal if I saw any chance of success).

Ciao,
Olaf
_______________________________________________
Haskell-prime mailing list
[email protected]
http://haskell.org/mailman/listinfo/haskell-prime

Reply via email to