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
  [email protected]http://www.joachim-breitner.de/
  Jabber: [email protected]  • GPG-Key: 0x4743206C
  Debian Developer: [email protected]

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
ghc-devs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/ghc-devs

Reply via email to