-XStrict: Why some binders are not made strict?
Roman Cheplyaka
roma at ro-che.info
Fri Dec 11 06:54:28 UTC 2015
On 12/10/2015 04:34 PM, Johan Tibell wrote:
> I'm snowed under but I promise I will try to reply soon! To think about
> in the mean time: what do existing strict languages with pattern
> matching do?
Well, strict languages do not have lazy data to force to begin with, do they?
Personally, I find the simple intuition of "all patterns are strict by default" rather appealing.
E.g. I wouldn't expect the expressions
let (v1,v2) = a in f v2
and
let (v1,v2) = a; v3 = v2 in f v3
to have different semantics.
If we decide to adopt this semantics, we need to address the meaning of the pattern
~(v1, v2)
under -XStrict. Intuitively, ~ should propagate to the subpatterns. An alternative is to disallow this pattern under -XStrict and require writing all ~s explicitly, which may get tedious:
~(~v1, ~v2)
~(~v1, ~(~v2, ~v3))
etc.
We also need to ensure the consistency between this extension and the unlifted data types proposal [1], given their similarity. Interestingly, I don't see constructor patterns explained there either.
[1]: https://ghc.haskell.org/trac/ghc/wiki/UnliftedDataTypes#Dynamicsemanticsofunliftedtypes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20151211/473ed854/attachment.sig>
More information about the ghc-devs
mailing list