[GHC] #5820: defining instance in GHCi leads to duplicated instances

GHC cvs-ghc at haskell.org
Tue Feb 7 12:57:37 CET 2012


#5820: defining instance in GHCi leads to duplicated instances
---------------------------------+------------------------------------------
    Reporter:  guest             |       Owner:                  
        Type:  bug               |      Status:  new             
    Priority:  high              |   Milestone:  7.4.2           
   Component:  GHCi              |     Version:  7.4.1-rc1       
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by castor):

 * cc: castor@… (added)


Comment:

 This problem also occurs using non-user-defined types. Take a look at the
 snippet below:[[BR]]
 [[BR]]
 fernando at Castor ~/src $ cat Foo.hs[[BR]]
 instance Num Bool where[[BR]]
 fernando at Castor ~/src $ ghc/inplace/bin/ghc-stage2 --interactive -w
 Foo.hs[[BR]]
 GHCi, version 7.5.20120130: http://www.haskell.org/ghc/  :? for help[[BR]]
 Loading package ghc-prim ... linking ... done.[[BR]]
 Loading package integer-gmp ... linking ... done.[[BR]]
 Loading package base ... linking ... done.[[BR]]
 [1 of 1] Compiling Main             ( Foo.hs, interpreted )[[BR]]
 Ok, modules loaded: Main.[[BR]]
 *Main> :info Bool[[BR]]
 data Bool = False | True        -- Defined in `GHC.Types'[[BR]]
 instance Num Bool -- Defined at Foo.hs:1:10[[BR]]
 instance Bounded Bool -- Defined in `GHC.Enum'[[BR]]
 instance Enum Bool -- Defined in `GHC.Enum'[[BR]]
 instance Eq Bool -- Defined in `GHC.Classes'[[BR]]
 instance Ord Bool -- Defined in `GHC.Classes'[[BR]]
 instance Read Bool -- Defined in `GHC.Read'[[BR]]
 instance Show Bool -- Defined in `GHC.Show'[[BR]]
 *Main> instance Fractional Bool where[[BR]]
 *Main> :info Bool[[BR]]
 data Bool = False | True        -- Defined in `GHC.Types'[[BR]]
 instance Fractional Bool -- Defined at <interactive>:3:10[[BR]]
 instance Num Bool -- Defined at Foo.hs:1:10[[BR]]
 instance Num Bool -- Defined at Foo.hs:1:10[[BR]]
 instance Bounded Bool -- Defined in `GHC.Enum'[[BR]]
 instance Enum Bool -- Defined in `GHC.Enum'[[BR]]
 instance Eq Bool -- Defined in `GHC.Classes'[[BR]]
 instance Ord Bool -- Defined in `GHC.Classes'[[BR]]
 instance Read Bool -- Defined in `GHC.Read'[[BR]]
 instance Show Bool -- Defined in `GHC.Show'[[BR]]
 [[BR]]
 This was the simplest program with which I was able to reproduce the
 problem.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5820#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list