[GHC] #3220: type variables appearing only in type equality constraints are not generalized

GHC trac at galois.com
Tue May 12 05:36:07 EDT 2009


#3220: type variables appearing only in type equality constraints are not
generalized
-----------------------------+----------------------------------------------
Reporter:  guest             |          Owner:                         
    Type:  bug               |         Status:  new                    
Priority:  normal            |      Component:  Compiler (Type checker)
 Version:  6.10.2            |       Severity:  normal                 
Keywords:                    |       Testcase:                         
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple       
-----------------------------+----------------------------------------------
 {{{
 {-# LANGUAGE TypeFamilies, ScopedTypeVariables#-}

 class Foo m where
     type Bar m :: *
     action :: m -> Bar m -> m

 right x m = action m (Right x)

 right' :: (Either a b ~ Bar m, Foo m) => b -> m -> m
 right' x m = action m (Right x)

 instance Foo Int where
     type Bar Int = Either Int Int
     action m a = either (*) (+) a m

 main = print $ right (1::Int) (3 :: Int)
 }}}
 with the above code i get:
 {{{
 *Main> :type right

 right :: (Either Int b ~ Bar m, Foo m) => b -> m -> m
 }}}
 without the main definition i get instead:
 {{{
 *Main> :t right
 right :: (Either GHC.Prim.Any b ~ Bar m, Foo m) => b -> m -> m
 }}}

 while i expect the correct type to be the one of right'.
 It looks related to bug #1813

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


More information about the Glasgow-haskell-bugs mailing list