change to deriving in 6.7 ??
Simon Peyton-Jones
simonpj at microsoft.com
Mon Aug 20 17:53:38 EDT 2007
Yes, this is a change. To guarantee that we generate terminating instance declarations, GHC now insists that it can reduce the context of a derived instance to
instance (C a, D b) => ...
That is, the context of the instance decl must consist of (class applied to type variables). Without this constraint it's all too easy to generate non-terminating instances.
So the deriving mechanism works in straightforward cases, and for more complicated cases you have to write the instances yourself.
It's not impossible that the deriving mechanism could be made a little more liberal, but it errs on the conservative side at the moment. There's no workaround - -you just have to write the instance yourself.
I should document this
Simon
From: cvs-ghc-bounces at haskell.org [mailto:cvs-ghc-bounces at haskell.org] On Behalf Of Conal Elliott
Sent: 15 August 2007 23:37
To: cvs-ghc at haskell.org
Subject: change to deriving in 6.7 ??
I'm running ghc-6.7.20070802 and getting a new error message that didn't show up with ghc-6.6. Code:
-- | Pairing for unary type constructors.
newtype Pair1 f g a = Pair1 {unPair1 :: (f a, g a)}
deriving (Eq, Ord, Show)
Error message:
src/Data/Tupler.hs:26:0:
No instances for (Show (g a), Show (f a))
arising from the 'deriving' clause of a data type declaration
at src/Data/Tupler.hs:(26,0)-(27,25)
Possible fix:
add an instance declaration for (Show (g a), Show (f a))
When deriving the instance for (Show (Pair1 f g a))
Has there been a change to "deriving"? Is there a workaround?
Thanks, - Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/cvs-ghc/attachments/20070820/3f6cb76b/attachment.htm
More information about the Cvs-ghc
mailing list