Opened 9 years ago

Closed 8 years ago

#3220 closed bug (fixed)

type variables appearing only in type equality constraints are not generalized

Reported by: guest Owned by:
Priority: normal Milestone: 6.12.1
Component: Compiler (Type checker) Version: 6.10.2
Keywords: Cc: sanzhiyan@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: T3220
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


{-# 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

Change History (2)

comment:1 Changed 9 years ago by igloo

difficulty: Unknown
Milestone: 6.12.1

Thanks for the report.

comment:2 Changed 8 years ago by chak

Resolution: fixed
Status: newclosed
Test Case: T3220

This problem has already been fixed in the HEAD. I added the example (slightly modified) as a regression test.

Note: See TracTickets for help on using tickets.