Deriving Data at higher kinds
Here's what Lennart Spitzner wanted to do:
> {-# LANGUAGE StandaloneDeriving #-}
> {-# LANGUAGE DeriveDataTypeable #-}
> {-# LANGUAGE FlexibleInstances #-}
>
> import Data.Data ( Data )
>
> data Foo f = Foo (f Bool) (f Int)
>
> deriving instance Data (Foo [])
> deriving instance Data (Foo Maybe)
Of course you can't derive Data
for Foo
because we don't know what f
is, so Lennart is making multiple instances, one for each instance of f
. It's a bit clumsy. What we would really like is
deriving instance (forall a. Data => Data (f a)) => Data (Foo f)
but we don't have higher order instances yet! So Lennart is manually making two instances.
This should work, but he gets
> Main.hs: line 45, column 1:
> Multiple declarations of ‘$cr2C’
> Declared at: Main.hs:44:1
> Main.hs:45:1
> Main.hs: line 45, column 1:
> Multiple declarations of ‘$tr2D’
> Declared at: Main.hs:44:1
> Main.hs:45:1
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |