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

GHC ghc-devs at haskell.org
Thu Aug 6 21:26:39 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 oerjan):

 Since you said not to mind Safe Haskell, I also found a similar
 unsoundness that uses loading of modules instead. All the modules can be
 `Safe`, but GHCi itself cannot have the flag set.

 {{{
 {-# LANGUAGE Safe, TypeFamilies #-}

 module T1 where

 type family T a b
 }}}

 {{{
 {-# LANGUAGE Safe, TypeFamilies #-}

 module T2 where

 import T1

 type instance T a b = a

 from :: a -> T a b
 from = id
 }}}

 {{{
 {-# LANGUAGE Safe, TypeFamilies #-}

 module T3 where

 import T1

 type instance T a b = b

 to :: T a b -> b
 to = id
 }}}

 Now in GHCi:

 {{{
 Prelude> :l T2 T3
 [1 of 3] Compiling T1               ( T1.hs, interpreted )
 [2 of 3] Compiling T3               ( T3.hs, interpreted )
 [3 of 3] Compiling T2               ( T2.hs, interpreted )
 Ok, modules loaded: T2, T1, T3.
 *T2> :m +T3
 *T2 T3> let uc = to . from
 *T2 T3> uc 'a' :: Int
 97
 }}}

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


More information about the ghc-tickets mailing list