[GHC] #7102: Type family instance overlap accepted in ghci

GHC ghc-devs at haskell.org
Fri Aug 7 08:36:22 UTC 2015


#7102: Type family instance overlap accepted in ghci
-------------------------------------+-------------------------------------
        Reporter:  exbb2             |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  GHCi              |                 Version:  7.4.1
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  GHC accepts       |  Unknown/Multiple
  invalid program                    |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Eek.  Of course GHCi should do an eager instance-overlap check when
 loading modules, just as GHC does.  That is a serious bug.  Again, nothign
 to do with Safe Haskell; your example works just as well without `{-#
 LANGUAGE Safe #-}`.

 Would anyone like to look at it? The code is all there, since it is used
 for dealing with imports in GHC.

 > I suspect the purging in (2) can already be achieved by just redeclaring
 the type family, after which new instances would refer to the new entity.

 Ah yes, that is true.  Clever.  So this is what would happen
 {{{
 Prelude> type family T a b
 Prelude> type instance T a b = a
 Prelude> let uc :: a -> T a b; uc = id

 Prelude> type instance T a b = b
 ERROR: instance overlap

 -- User thinks: darn!  Re-declare T
 Prelude> type family T a b
 -- This is a brand-new T, unrelated to the old one

 Prelude> uc 'a' :: Int
 <interactive>:6:1: error:
     Couldn't match type ‘Char’ with ‘Int’
     Expected type: Int
       Actual type: Ghci1.T Char b0
 }}}
 So, no need to add a new facility for purging.  What we need is to reject
 overlap.

 Simon

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


More information about the ghc-tickets mailing list