Skip to content

Incoherent instances without -XIncoherentInstances

Consider the following 4 modules:

{-# LANGUAGE GADTs #-}

module A where

data One = One

data ShowInstFor a = Show a => MkSIF

incoherent :: ShowInstFor One -> ShowInstFor One -> String
incoherent MkSIF MkSIF = show One
module B where

import A

instance Show One where
  show _ = "from module B"

fromB :: ShowInstFor One
fromB = MkSIF
module C where

import A

instance Show One where
  show _ = "from module C"

fromC :: ShowInstFor One
fromC = MkSIF
module D where

import A
import B
import C

oops1 = incoherent fromB fromC
oops2 = incoherent fromC fromB

According to ghci, oops1 is "from moduleB" and oops2 is "from module C". This seems bad.

Trac metadata
Trac field Value
Version 7.6.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information