Newtype wrappers

Johan Tibell johan.tibell at
Mon Jan 14 22:32:54 CET 2013

On Mon, Jan 14, 2013 at 1:19 PM, Simon Peyton-Jones
<simonpj at> wrote:
> Have you considered the effect on types like Data.Set that use the
> uniqueness of typeclass instances to maintain invariants? e.g. even when we
> have "newtype X = X Y" coercing "Set X" to "Set Y" can produce a tree with
> the wrong shape for the Ord instance of Y.
> Good point. I should add this.  The wrapper should only work if the relevant
> data constructors are in scope; rather like GHC’s existing auto-unwrapping
> on foreign calls
> (

I don't follow. Are you saying that adding an import, even if nothing
from that import is used, can effect if the program compiles?

Does that mean if we ever add Data.Map.Internal that exposes the data
constructors to users who "know what they're doing" (i.e. are willing
to take it upon themselves to maintain the invariants) then code that
used to compile will stop to do so?

More information about the Glasgow-haskell-users mailing list