[Haskell-cafe] Orphan instances

Henning Thielemann lemming at henning-thielemann.de
Wed Mar 5 01:53:19 EST 2008

Consider the following modules

module A

class A t

module T

import A

data T a

module B

import A
import T

class A t => B t

instance B t => A (T t)

GHC emits warning about orphan instance A (T t), since neither A nor T are 
defined in B. However I can't move the instance to A or T since it depends 
on B. Would it be fine to lift the restriction, such that it is accepted 
to declare the instance in a module where the type or the class or a 
superclass (this is new) is defined?

In my example class B provides conversion toInteger (that is Integral), 
class A provides conversion toRational (that is Real) and T is Ratio.

More information about the Haskell-Cafe mailing list