Coercible class (Was: newtype wrappers)

Joachim Breitner mail at
Sun Sep 15 21:13:52 UTC 2013


Am Sonntag, den 15.09.2013, 16:48 -0400 schrieb Richard Eisenberg:
> What was the end result of the discussion on abstraction? Can a
> library control how its types are coerced?

there is no end result, as this is just a language feature. But the
current state of affairs is that:
 * A newtype can be casted only if its constructor is visible.
 * Casting below a type constructor (instance Coercible a b => Coercible
(Maybe a) (Maybe b)) is possible if the roles allow it; the constructor
does not have to be visible or exposed, except that
 * in Safe Haskell code, the constructor or the typecon (and all
constructors of all typecons used in the definition of the typecon) has
to be visible.

So once you know your syntax for role annotations it would make sense to
annotate the arguments of Set and Map (first one only) in base before we
release 7.8.


PS: Do we have regular builds of master, including users’ guide and
haddock, somewhere that I can link to in such a mail?

Joachim Breitner
  e-Mail: mail at
  ICQ#: 74513189
  Jabber-ID: nomeata at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the ghc-devs mailing list