Christian Maeder maeder at tzi.de
Tue Nov 30 09:14:52 EST 2004

Ralf Laemmel wrote:
> I still have to see a good reason to use "-fallow-incoherent-instances".

The motivation came from SPJ for the following example:

type Inte a = (Integer,a)
instance Show a => Show [Inte a]

data Bar b = Bar [b]
instance Show b => Show (Bar b) where
     show (Bar x1) = show x1

This only compiles with the additional -fallow-incoherent-instances 
flag. However, if the first bit is put in Module B1 and the second in 
module A1, then module B1 does not need -fallow-incoherent-instances and 
module A1 (surprise!) does not even need -fglasgow-exts to go through. 
Rather module A1 yields an error if called with -fglasgow-exts and 
-fallow-overlapping-instances alone:

     Could not unambiguously deduce (Show [b])
         from the context (Show (Bar b), Show b)
       arising from use of `show' at A1.hs:9
     The choice of (overlapping) instance declaration
         depends on the instantiation of `b'
     Probable fix:
         Add (Show [b]) to the class or instance method `show'
         Or add an instance declaration for (Show [b])
     In the definition of `show': show (Bar x1) = show x1
     In the definition for method `show'
     In the instance declaration for `Show (Bar b)'

So instead of adding the flag -fallow-incoherent-instances also the flag
-fno-allow-overlapping-instances lets A1 go through. Thus globally 
setting -fallow-overlapping-instances is already a problem.


P.S. The unfortunate instance originally comes from module 
-- type LPath a = [LNode a]

instance Eq a => Eq (LPath a)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A1.hs
Type: text/x-haskell
Size: 178 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/glasgow-haskell-users/attachments/20041130/2e315796/A1.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: B1.hs
Type: text/x-haskell
Size: 138 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/glasgow-haskell-users/attachments/20041130/2e315796/B1.bin

More information about the Glasgow-haskell-users mailing list