Are safe coercions safe in the sense of Safe Haskell?

Richard Eisenberg eir at
Fri Aug 15 23:40:01 UTC 2014

See and which discuss this problem at length.

The short answer: It's conceivable that a role-unaware library author would have abstraction expectations that are defeated through the use of `coerce`.

I would strongly welcome a proposal for how to make `coerce`, and hence GeneralizedNewtypeDeriving, to be considered Safe for 7.10.


On Aug 15, 2014, at 4:04 PM, Wolfgang Jeltsch <g9ks157k at> wrote:

> Hi,
> I would expect the function
>    coerce :: Coercible a b => a -> b
> to be safe in the sense of Safe Haskell. However, the Data.Coerce module
> is marked “Unsafe”. The coerce function is also available via GHC.Exts
> and GHC.Prim. The former module is marked “Unsafe”, but the latter is
> (surprisingly) marked “Safe-Inferred”.
> What are the reasons behind this?
> All the best,
> Wolfgang
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list