Opened 2 years ago

Closed 19 months ago

#6083 closed feature request (wontfix)

GeneralizedNewtypeDeriving: "deriving ALL"

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

Description

I've found I've wanted to do:

newtype X1 = X1 ( X ) deriving ( ALL );
newtype X2 = X2 ( X ) deriving ( ALL );

When I want X1, X2 to behave like X, but I might later want to add them to different instances, i.e.

class Silly a

double
a -> a

instance Silly X1 where

double x = 2 * x

instance Silly X2 where

double x = 3 * x -- Silly double

Currently, it seems to be the only way to do this is to dig into the source of X and find every instance it has. It would be nice to be able to simply to "deriving ALL" to make XN in "newtype XN = XN X" behave exactly the same as X.

Change History (2)

comment:1 Changed 2 years ago by clinton

(Repost with better formatting)

I've found I've wanted to do:

newtype X1 = X1 ( X ) deriving ( ALL )
newtype X2 = X2 ( X ) deriving ( ALL )

When I want X1, X2 to behave like X, but I might later want to add them to different instances, i.e.

class Silly a where
  double :: a -> a

instance Silly X1 where
  double x = 2 * x

instance Silly X2 where
  double x = 3 * x -- Silly double

Currently, it seems to be the only way to do this is to dig into the source of X and find every instance it has. It would be nice to be able to simply to "deriving ALL" to make XN in "newtype XN = XN X" behave exactly the same as X.

comment:2 Changed 19 months ago by igloo

  • Difficulty set to Unknown
  • Resolution set to wontfix
  • Status changed from new to closed

Thanks for the suggestion. However, the interaction of this with orphan instances sounds tricky. Unless there's a lot more demand for it I don't think that it's worthwhile.

Note: See TracTickets for help on using tickets.