[GHC] #5462: Deriving clause for arbitrary classes
GHC
cvs-ghc at haskell.org
Thu Sep 8 08:17:47 CEST 2011
#5462: Deriving clause for arbitrary classes
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.2.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by dreixel):
One extra issue to consider is that the instance head is not trivial to
generate. Say we have an arbitrary deriving clause:
{{{ data MyDatatype a = C1 | C2 a (MyDatatype a) deriving MyClass }}}
We want to convert it into an empty instance:
{{{ instance (...) => MyClass (MyDatatype a) }}}
But how do we fill in the constraints? This depends on both `MyClass` and
`MyDatatype`, and in a non-trivial way, as far as I can see. E.g., if
`MyClass` implements a `show` function, we probably want the `MyClass a`
constraint. But if `a` was actually a phantom type, then we don't. Nor if
`MyClass` computes shallow equality, for instance. Things get even worse
when `MyDatatype` is not a regular type (think of nested datatypes, or
types with higher-order arguments).
This problem does not occur when standalone deriving is used, because then
the user specifies the constraints directly. But I guess that limiting
this new feature to standalone deriving would make it a bit inconsistent,
and also defeat the purpose of extra compactness/simplicity.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5462#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list