Ticket #2668 (closed merge: fixed)

Opened 5 years ago

Last modified 5 years ago

Standalone deriving doesn't do newtype deriving properly

Reported by: ryani Owned by: igloo
Priority: normal Milestone: 6.10.1
Component: Compiler Version: 6.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I'd expect the following two declarations to have identical behavior:

newtype S1 x y a = S1 (M S x y a) deriving IxMonad

newtype S2 x y a = S2 (M S x y a)
deriving instance IxMonad S2

Results:

$ ghc-6.11.20081005 -c deriving.hs

deriving.hs:15:0:
    Can't make a derived instance of `IxMonad S2'
      (even with cunning newtype deriving:
       the representation type has wrong kind)
    In the stand-alone deriving instance for `IxMonad S2'

Attachments

deriving.hs Download (320 bytes) - added by ryani 5 years ago.

Change History

Changed 5 years ago by ajd

When I comment out the standalone stuff, GHC gives the message

The equation(s) for 'ret' have one argument,
but its type 'M s i i a' has none
In the definition for the method 'ret'
In the instance declaration for IxMonad (M s)

which seems kind of similar...

I'm using 6.8.2 on Windows.

Changed 5 years ago by ryani

Oops, that was just a typo in my test case.

Change the instance to declare ret as

   ret :: a -> m i i a

It compiles fine with the standalone commented out in GHC6.8.3 but gives the same error with it in.

I'll upload a fixed attachment.

Changed 5 years ago by ryani

Changed 5 years ago by simonpj

  • difficulty set to Unknown

Excellent report. That's a bug. I'll get to it.

Simon

Changed 5 years ago by igloo

  • milestone set to 6.10.1

Changed 5 years ago by simonpj

  • owner set to igloo
  • type changed from bug to merge

Fixed by

Tue Oct 21 07:29:22 PDT 2008  simonpj@microsoft.com
  * Fix Trac #2668, and refactor TcDeriv

Pls merge

Changed 5 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged

Note: See TracTickets for help on using tickets.