[GHC] #3205: Generalized isomorphic deriving
GHC
trac at galois.com
Sun May 3 16:58:20 EDT 2009
#3205: Generalized isomorphic deriving
-----------------------------+----------------------------------------------
Reporter: ajd | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 6.10.2 | Severity: normal
Keywords: | Testcase:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
-----------------------------+----------------------------------------------
A newtype is isomorphic to the type that it is based on. For example,
newtype A = A Int is isomorphic to Int, so it is possible to automatically
derive all of Int's instance for A.
It would be nice if this could be extended to other datatypes that were
isomorphic to each other. For example, this would work
{{{
data K a = K a a a
instance C (K a) where
...
data L a = L a a a
deriving (Eq,C<-K,Show)
}}}
where the {{{C<-K}}} notation means "derive an instance of C for this type
that is 'the same as' the instance of C for K". The compiler would have to
check that K and L were actually isomorphic.
I don't know if this is possible with the current internals of GHC, but it
would be cool if it would be done. My main usage scenario would be
deriving things for single-argument data constructors based on tuples; for
example for serialization classes.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3205>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list