Exposing newtype coercions to Haskell

Richard Eisenberg eir at cis.upenn.edu
Wed Jul 31 23:10:18 CEST 2013

Hi Joachim,

As discussed previously, I do think we need a way to store representational coercions. In my roles branch (which is getting close to pushing, I believe), I have created eqReprPrimTyCon, which is like eqPrimTyCon, but it is the type of coercions witnessing representational equality. The Id stored in a CoVarCo can usefully have a type headed by eqReprPrimTyCon.

If you're really eager to take a look, I use github to coordinate among computers; you can see the roles branch at github.com/goldfirere/ghc.


On Jul 24, 2013, at 8:31 AM, Joachim Breitner wrote:

> Hi,
> Am Dienstag, den 23.07.2013, 18:58 +0000 schrieb Simon Peyton-Jones:
>> If you add -XIncoherentInstances *just to the module that has instance
>> IsNT a a*, then it'll work fine I think.  This says "pick this
>> instance even though an instantiation of the constraint might match a
>> more specific instance".  You don't need the flag in importing
>> modules.
> That does not seem to be the case: Enabling the flag just for the
> special "IsNT a a" instance does not work:
> Prelude GHC.NT> :t  castNT :: (Either Int a) -> (Either Age a)
> <interactive>:1:1:
>    Overlapping instances for IsNT a1 a1 arising from a use of ‛castNT’
>    Matching instances:
>      instance [incoherent] IsNT a a -- Defined at <interactive>:12:10
>      instance (IsNT a a', IsNT b b') => IsNT (Either a b) (Either a' b')
>        -- Defined at <interactive>:7:1
>    (The choice depends on the instantiation of ‛a1’
>     To pick the first instance above, use -XIncoherentInstances
>     when compiling the other instance declarations)
>    In the expression: castNT :: (Either Int a) -> (Either Age a)
> (as correctly specified by the error message.)
> But now the solution is easy to see: When deriving IsNT, simply set the
> incoherent flag for every instance, independent of any active pragmas.
> Greetings,
> Joachim
> -- 
> Joachim “nomeata” Breitner
>  mail at joachim-breitner.dehttp://www.joachim-breitner.de/
>  Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0x4743206C
>  Debian Developer: nomeata at debian.org
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://www.haskell.org/mailman/listinfo/ghc-devs

More information about the ghc-devs mailing list