[GHC] #4083: Generalized newtype deriving fails for newtypes
that are type family instances
GHC
cvs-ghc at haskell.org
Tue May 25 03:22:35 EDT 2010
#4083: Generalized newtype deriving fails for newtypes that are type family
instances
--------------------------------------+-------------------------------------
Reporter: RANDY Ruler of Zexernet | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 6.12.1
Resolution: invalid | Keywords:
Difficulty: | Os: Unknown/Multiple
Testcase: | Architecture: Unknown/Multiple
Failure: None/Unknown |
--------------------------------------+-------------------------------------
Changes (by simonpj):
* status: new => closed
* resolution: => invalid
Comment:
Thanks. It's definitely a bug that you get an 'impossible' error,
fortunately fixed in 6.12.3:
{{{
T4083.hs:6:1:
Can't make a derived instance of `C (F [a])'
(even with cunning newtype deriving):
the class has associated types
In the stand-alone deriving instance for
`(C (Maybe a)) => C (F [a])'
}}}
And indeed, generalised newtype deriving doesn't support classes with
associated types. Remember it's just a mechanism for saving you typing.
So suppose you had
{{{
class C a where
data T a
op :: a -> T a
instance C Int where
data T Int = TI Bool
op n = TI (n>0)
newtype Age = MkAge Int deriving( C )
}}}
What instance declaration would GHC generate? Something like
{{{
instance C Age where
data T Age = ???
op (Age n) = ???
}}}
The trouble is that each instance generates fresh data constructors.
Anyway at the moment it's just not supported, and you now get a civilised
message to that effect.
I'll close as 'invalid', but I really mean 'not supported'. You could
open a feature request, but I'm quite unsure what the design would look
like. (It might be just possible for associated type *synonyms* but I'm
not certain.)
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4083#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list