3
votes

I am trying to derive a Typeable instance for (':)

I am using DataKinds and [*].

I have TypeOperators, StandaloneDeriving and PolyKinds enabled

I cannot derive an instance of typeable

I have tried

deriving instance Typeable (':)

and

deriving instance Typeable ':

and

deriving instance Typeable ((':))

but they all get parse errors.

I know that if I write

data List a = Cons a (List a) | Empty

deriving instance Typeable (Cons)

I get the expected outcome but I do not wish to rewrite my existing code to use a custom list type.

1
Very interesting that you can derive an instance for '[], but not for ': this way. For anyone else who wants to try this, you'll need DataKinds, PolyKinds, DeriveDataTypeable, and StandaloneDeriving. - crockeea

1 Answers

8
votes

This seems to work

 deriving instance Typeable '(:)

Presumably the ' is designed to mark the "whole type constructor", including if it's sectioned? Seems a bit weird to me. This is consistent with tuples however, where you would write

'(a, b)