[RFC] Bang constraint

Isaac Dupree ml at isaac.cedarswampstudios.org
Wed Apr 3 21:28:49 CEST 2013


On 04/03/2013 02:06 PM, Gabor Greif wrote:
> Now that Constraint kinds are pretty much into the mainstream, can we
> consider the '!' annotation in data declarations as a magic
> constraint? Not unlike NFData, but only ensuring that said value is in
> WHNF.
>
> So the following definitions would be semantically identical
>
>> newtype Foo a = Foo a
>
>> data Foo a = Foo !a
> [...]

These two are not identical because
   f (Foo _) = 3
forces the value if it's 'data' but not if it's 'newtype'.
That's irrelevant to your interesting proposal, however.

-Isaac



More information about the ghc-devs mailing list