Ticket #2102 (closed bug: fixed)
Typeclass membership doesn't bring coercion superclass requirements into scope
| Reported by: | ryani | Owned by: | chak |
|---|---|---|---|
| Priority: | low | Milestone: | 7.2.1 |
| Component: | Compiler (Type checker) | Version: | 7.1 |
| Keywords: | superclass equalities | Cc: | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Compile-time crash | Difficulty: | Unknown |
| Test Case: | indexed_types/should_compile/T2102 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
-- 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.
Change History
Note: See
TracTickets for help on using
tickets.
