~ patterns
Simon Marlow
simonmar at microsoft.com
Fri Jan 27 06:21:25 EST 2006
On 27 January 2006 10:50, John Hughes wrote:
> I'd be fairly horrified at the removal of ~ patterns. I've used them
> to fix very serious space-leaks that would have been awkward to fix
> in any other way.
You use them to *fix* space leaks? Can you give an example? I'm
genuinely surprised and interested - I don't think I've ever seen a case
of this before, but I've seen the opposite many times (lazy pattern
matching being the cause of space leaks).
The reasoning behind removing ~ patterns, for me, is that the number of
times they are used doesn't justify stealing the ~ symbol and the extra
complexity in the language design, when you can get the same effect with
let bindings. With pattern guards there's even less justification for
keeping ~, eg.
f (a, ~(x:xs)) = e
turns into
f (a,b) | let (x:xs) = b = e
you can translate any equation this way. I would probably write the
second form in prefernce to the first, because the strict pattern
matches are clearly separated from the lazy.
I admit to being slightly biased though, in the type of Haskell
programming I do I have almost never needed to use ~. Very occasionally
when doing cyclic programming, is all.
Cheers,
Simon
More information about the Haskell-prime
mailing list