-XStrict: Why some binders are not made strict?

Ömer Sinan Ağacan omeragacan at gmail.com
Fri Dec 11 22:21:37 UTC 2015


I agree with Roman here.

Probably another reason for making every binding strict is this: (sorry if this
is mentioned)

Suppose I imported `data D = D ...` from another library and I'm in -XStrict.
In this code:

    case ... of
      D b1 b2 ... -> <body>

I should be able to assume that b1, b2 ... etc. are all strict(that is, WHNF in
<body>) becuase I'm in -XStrict. This also makes the behavior more consistent,
I think.

2015-12-11 7:57 GMT-05:00 Roman Cheplyaka <roma at ro-che.info>:
> On 12/11/2015 02:21 PM, Johan Tibell wrote:
>> If we force strictness all the way down it's not really call-by-value
>> either, because the caller doesn't know what to evaluate (I think).
>
> Not sure what you mean here.
>
>> In addition, making pattern matching strict in this way makes it hard to
>> mix and match strict and lazy data types (e.g. Maybe), because using a
>> lazy data type from another module will make it appear strict in your
>> code (hurting modularity).
>
> I don't think this is a case about modularity. A lazy Maybe value
> defined in a lazy module remains lazy; and you can pass it to lazy
> functions without forcing it. Only when you pattern match on it *in the
> strict module*, the evaluation happens.
>
> As I said, I prefer this semantics mainly because it's easier to
> explain: all variables (and underscores) bound in a strict module refer
> to WHNF values. Do you have a similarly simple explanation for the
> semantics you're suggesting?
>
> Roman
>
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>


More information about the ghc-devs mailing list