#2356: GHC accepts multiple instances for the same type in different modules
----------------------+-----------------------------------------------------
Reporter: claus | Owner:
Type: bug | Status: new
Priority: low | Milestone: _|_
Component: Compiler | Version: 6.8.3
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
----------------------+-----------------------------------------------------
Comment (by igloo):
Here is an example of Data.Set going wrong due to multiple instances:
{{{
module Type where
data Foo = F1 | F2 | F3
deriving (Eq, Show)
}}}
{{{
module Create where
import Data.Set
import Type
instance Ord Foo where
x `compare` y = show x `compare` show y
s :: Set Foo
s = fromList [F1, F2, F3]
}}}
{{{
module Consume where
import Data.Set
import Type
instance Ord Foo where
x `compare` y = show y `compare` show x
f :: Set Foo -> Bool
f x = F1 `member` x
}}}
{{{
import Create
import Consume
main :: IO ()
main = print (f s)
}}}
{{{
$ ./Main
False
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2356#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs