
Dear GHC developers, Can you, please, explain what has happened in 6.5.20060831 with treating of overlapping instances? It seems to understand them differently than ghc-6.4.1. For example, I compile the module ------------------------ class C a where c :: a -> Bool instance C Int where c n = n > 0 instance C a => C [a] where c xs = and $ map c xs instance C [Int] where c xs = c $ head xs main = putStr (shows (c [1, (-2 :: Int)]) "\n") instance Show [Bool] where showsPrec _ xs = shows (head xs) ------------------------ with the options $dmCpOpt = -fglasgow-exts -fallow-undecidable-instances -fallow-overlapping-instances -fno-warn-overlapping-patterns -fwarn-unused-binds -fwarn-unused-matches -fwarn-unused-imports :
ghc $dmCpOpt --make Main
It reports -------------------------------------------------------- [1 of 1] Compiling Main ( Main.hs, Main.o ) Main.hs:11:0: Overlapping instances for Show [Bool] arising from use of `GHC.Show.$dmshowList' at Main.hs:11:0 Matching instances: instance (Show a) => Show [a] -- Defined in GHC.Show instance [overlap ok] Show [Bool] -- Defined at Main.hs:11:0 In the expression: GHC.Show.$dmshowList In the definition of `showList': showList = GHC.Show.$dmshowList In the definition for method `showList' -------------------------------------------- And it takes as all right the overlaps for the class C. [Bool] is a substitutional instance of [a], and according to the GHC specification, the Show instance for [Bool] must override the more generic one for Show a => [a]. Thank you in advance for explanation. ----------------- Serge Mechveliani mechvel@botik.ru