Typeclass membership doesn't bring coercion superclass requirements into scope
-- This works:
class C1 a where c1 :: a -> Int
class C1 a => C2 a where c2 :: a -> Int
test :: C2 a => a -> Int
test a = c1 a + c2 a
-- This doesn't work:
class (a ~ b) => E a b
cast :: E a b => a -> b
cast a = a
{- error:
tyfam.hs:36:9:
Couldn't match expected type `b' against inferred type `a'
`b' is a rigid type variable bound by
the type signature for `cast' at tyfam.hs:35:14
`a' is a rigid type variable bound by
the type signature for `cast' at tyfam.hs:35:12
In the expression: a
In the definition of `cast': cast a = a
-}
I would expect that the requirement of membership in E a b would bring (a ~ b) into scope and allow cast to typecheck.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.8.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |