Incoherent instance for Prelude type class accepted without incoherent instances option
If we create a new module allowing overlapping instances, flexible instances and undecidable instances we can define a function that selects an incoherent instance for a type class defined in the Prelude. Example:
> {-# OPTIONS -XFlexibleInstances -XOverlappingInstances -XUndecidableInstances #-}
> module Test where
> instance Show a => Eq a where
> x == y = length (show x) == length (show y)
>
> f :: Show a => a -> a -> Bool
> f x y = x == y
>
> p = f (3 :: Int) 4
The instance selected here (tested with GHC 7.0 and 6.12) is the one in this module, even if the instance Eq Int from the Prelude is more specific. If we try to reproduce a similar example using a module other than the Prelude, an incoherent instances error is reported. I believe that, for consistency the same should happen here.