
Hi, Right now, there is one rule: if the type of any variable bound in the
pattern is unlifted, then the pattern is an unlifter-var pattern and is strict.
I think the intuition I followed so far was "bindings with unlifted *RHS* are strict". So if I take a program in a strict language with Haskell syntax (Idris with a different syntax, not like -XStrict) and replace all types with their unlifted counterparts (which should be possible once we have -XUnliftedDatatypes), then I get exactly the same semantics in GHC Haskell. I find this property very useful. As a special case that means that any binders of unlifted type are bound strictly, if only for uniformity with simple variable bindings. I think my intuition is different to Richard's rule only for the "unlifted constructor match with nested lifted-only variable matches" case. Sebastian Am Do., 3. Sept. 2020 um 14:48 Uhr schrieb Spiwack, Arnaud < arnaud.spiwack@tweag.io>:
This thread is suggesting to add a special case -- one that seems to match
intuition, but it's still a special case. And my question is: should the special case be for unboxed tuples? or should the special case be for any pattern whose overall type is unlifted?
My intuition would be: for all unlifted types. I'd submit that the distinction between lazy and strict pattern-matching doesn't really make a ton of sense for unlifted types. To implement lazy pattern-matching on an unlifted type, one has to actually indirect through another type, which I find deeply suspicious.
That being said
Right now, there is one rule: if the type of any variable bound in the
pattern is unlifted, then the pattern is an unlifter-var pattern and is strict. The pattern must be banged, unless the bound variable is not nested. This rule is consistent across all features.
I realise that there are a lot of subtil details to get right to specify pattern-matching. Or at the very least, that it's difficult to come up with a straightforward specification which is as clear as the one above.
I'm wondering though: have there been discussions which led to the above rule, or did it just come to be, mostly informally? (and if there have been explicit discussions, are they recorded somewhere?) _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs