~ patterns

John Hughes rjmh at cs.chalmers.se
Fri Jan 27 05:50:19 EST 2006


>>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 think so too. Removing ~ patterns seems like a fairly poor idea to
>me. Sure, they're not very much explicitly used (though everyone uses
>them implicitly in pattern bindings), but when you want them, they can
>be fairly important. I think perhaps we just need better coverage of ~
>in the tutorials. Now that I think about it, I rather like the idea of
>! patterns as well. They make ~ patterns seem more natural by
>contrast. Strictness can on occasion be just as important as laziness,
>and this notation makes it more convenient to obtain in simple cases.
>How to get a similarly pretty notation for more structured strictness
>annotations is a bit of a concern. I wonder whether some of the
>Control.Parallel.Strategies library should be more strategically
>located? :)
>
> - Cale
>
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.  I suppose if lazy pattern matching were provided by some 
other mechanism, say via let bindings, then I should always in principle 
be able to translate away a ~ pattern. But the translation will often be 
much more awkward.

Actually, I think it's a much bigger wart that pattern matching in let 
and where is lazy, and everywhere else is strict, than that we have an 
operator ~ on patterns with a clean compositional semantics. Way back in 
the Haskell 98 process I tried to get that changed--so that patterns 
would be matched strictly EVERYWHERE unless you wrote ~ --but I lost 
that argument.

John


More information about the Haskell-prime mailing list