Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deriving a Typeable instance for (':)

Tags:

haskell

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.

like image 637
Alex Avatar asked Aug 26 '26 10:08

Alex


1 Answers

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)
like image 149
Daniel Gratzer Avatar answered Aug 29 '26 00:08

Daniel Gratzer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!