Changes between Initial Version and Version 2 of Ticket #2721


Ignore:
Timestamp:
Dec 31, 2008 4:33:18 PM (7 years ago)
Author:
simonpj
Comment:

Good point. For now I'm just going to make it fail. It's quite a bit more work to make it generate the extra instance, and the fact that it does not work at all for 'data' convinced me.

It's annoying that you therefore cannot do newtype-deriving for a class with an associated type. An alternative is to allow top-level declarations for associated types, and check that these exist when doing the instance decl. So this would be valid:

class C a where
  type T a
  op :: a -> T a

type instance T Int = Bool
instance C Int where
  op x = True

So I'll leave this open to record the idea, but meanwhile I'll push a patch to make it fail uniformly.

Simon

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #2721

    • Property Test Case changed from to deriving/should_fail/T2721
    • Property Difficulty changed from to Unknown
    • Property Milestone changed from to 6.10.2
  • Ticket #2721 – Description

    initial v2  
    3030newtype N = N Int deriving(C)
    3131}}}
    32 I guess this last example is the same bug as `#1496`. I wonder if the deriving clause could generate something like:
     32I guess this last example is the same bug as #1496. I wonder if the deriving clause could generate something like:
    3333{{{
    3434instance T Int ~ T N => C Int