Can't make a derived instance of `Typeable (A B)': `A' has arguments of kind other than `*'

Suppose I have a data type: data A f = A { a :: f Integer } why can't I derive a Typeable instance like so? deriving instance Typeable (A Maybe) I get: Can't make a derived instance of `Typeable (A Maybe)': `A' has arguments of kind other than `*' In the stand-alone deriving instance for `Typeable (A Maybe)' I would have expected that the arguments are instantiated by the Maybe type constructor and thus the type of A would be: Maybe Integer -> A What am I missing?

Just for what it's worth, the following does work: newtype AMaybe = AMaybe { unMaybe :: A Maybe } deriving instance Typeable AMaybe Which leads me to be kind of baffled by the above error message.

Actually I suppose the newtype one makes sense because it's opaque and not paramerized so it doesn't inspect the unMaybe. I'll think about this some more.

On 24 September 2010 22:18, Christopher Done
Can't make a derived instance of `Typeable (A Maybe)': `A' has arguments of kind other than `*' In the stand-alone deriving instance for `Typeable (A Maybe)'
Nevermind, I figured it out. The arguments refer to the type constructor A. I'll think some more before posting a thread next time. Ciao!

There is added complication because there are two possible extensions
that can derive that instance: either GeneralizedNewtypeDeriving or
DerivingDataTypeable. I think the latter always wins (which makes
sense, it's probably what you want).
-- ryan
On Fri, Sep 24, 2010 at 1:41 PM, Christopher Done
On 24 September 2010 22:18, Christopher Done
wrote: Can't make a derived instance of `Typeable (A Maybe)': `A' has arguments of kind other than `*' In the stand-alone deriving instance for `Typeable (A Maybe)'
Nevermind, I figured it out. The arguments refer to the type constructor A. I'll think some more before posting a thread next time. Ciao! _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

You can't automatically derive Typeable for any type with a kind that
has any arguments that aren't of type *.
For instance, you can derive an instance for a type with a kind *, *
-> *, or even * -> * -> * -> * -> * -> *, but not one with a kind (*
-> *) -> *.
And your type A there has kind (* -> *) -> *. You'll have to manually
write a Typeable instance if you want one. The process is somewhat
trickier than you might expect, due to the fact that Typeable does
some unsafe stuff. But there are plenty of examples for how to do it
safely.
Enjoy the fun of not having kind polymorphism!
Carl Howells
On Fri, Sep 24, 2010 at 1:18 PM, Christopher Done
Suppose I have a data type:
data A f = A { a :: f Integer }
why can't I derive a Typeable instance like so?
deriving instance Typeable (A Maybe)
I get:
Can't make a derived instance of `Typeable (A Maybe)': `A' has arguments of kind other than `*' In the stand-alone deriving instance for `Typeable (A Maybe)'
I would have expected that the arguments are instantiated by the Maybe type constructor and thus the type of A would be:
Maybe Integer -> A
What am I missing? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Carl Howells
-
Christopher Done
-
Ryan Ingram