Ticket #2721 (new feature request)
Newtype deriving doesn't work with type families
| Reported by: | rl | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 7.4.1 |
| Component: | Compiler | Version: | 6.10.1 |
| Keywords: | Cc: | tom.schrijvers@…, illissius@… | |
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | deriving/should_fail/T2721 | Blocked By: | |
| Blocking: | Related Tickets: |
Description (last modified by simonpj) (diff)
This assumes -XTypeFamiles -XGeneralizedNewtypeDeriving. Example:
class C a where type T a foo :: a -> T a instance C Int where type T Int = Int foo = id newtype N = N Int deriving(C)
This happily produces an instance C N but no type instance T N. It should either (preferably) generate
type instance T N = Int
or fail. The example also compiles if T is a data family (the Int instance needs to be change accordingly). It should probably fail in this case.
BTW, this also compiles fine, with rather dramatic consequences:
type family T a class C a where foo :: a -> T a type instance T Int = Int instance C Int where foo = id type instance T N = Double newtype N = N Int deriving(C)
I guess this last example is the same bug as #1496. I wonder if the deriving clause could generate something like:
instance T Int ~ T N => C Int
Change History
Note: See
TracTickets for help on using
tickets.
