Backward-compatible role annotations

Henning Thielemann schlepptop at
Mon Mar 31 07:43:11 UTC 2014

Am 31.03.2014 08:51, schrieb Dominique Devriese:
> Richard,
> (re-posting because I first used an address that is not subscribed to the lists)
> I've been wondering about the following: it seems like the main
> problem in this situation is that the GeneralizedNewtypeDeriving
> extension changed meaning from "just coerce everything while deriving"
> to "only coerce stuff if it's allowed by the relevant role
> annotations".  Would it not be an alternative solution to split up the
> GND extension into
> * a backwards-compatible one (called GeneralizedNewtypeDeriving for
> backwards compatibility ;)) that ignores role annotations (as before)
> and uses unsafeCoerce whereever necessary
> * a safe one (called e.g. SafeNewtypeDeriving) that respects role annotations

That's very similar to what I proposed with respect to SafeHaskell, i.e. 
GeneralizedNewtypeDeriving in an Unsafe module means 
backwards-compatible old GeneralizedNewtypeDeriving and 
GeneralizedNewtypeDeriving in a Safe module means SafeNewtypeDeriving.

 > P.S.: The above is based on a limited understanding of the problem, so
 > I'm sorry if it misses some aspect of the problem...

I think their main concern is not on the side of the user who wants to 
use GeneralizedNewtypeDeriving, but on the side of the library writer 
who has to take GeneralizedNewtypeDeriving into account, although it is 
an extension and his code would be perfectly safe without 
GeneralizedNewtypeDeriving. The first one is a problem only in the 
transition from GHC-7.6 to GHC-7.8, but the latter one is a permanent 

But then again, the backward-compatible role annotations proposal seems 
to address yet another problem.

More information about the Libraries mailing list