Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constructor that lifts (via DataKinds) to * -> A

Given an ADT like

data K = A | B Bool

the DataKinds extension allows us to lift it into kinds and types/type constructors

K :: BOX
'A :: K
'B :: 'Bool -> K

Is there a way to add a constructor to K that lifts to the type constructor

'C :: * -> K

?

like image 873
Cactus Avatar asked Jun 11 '15 13:06

Cactus


2 Answers

As Conor states, this is not directly possible. You can, however, define

data K a = ... | C a

Then this promotes to

C :: a -> K a

If you then use K *, you can achieve what you want.

like image 56
kosmikus Avatar answered Sep 21 '22 22:09

kosmikus


At the moment, I'm afraid not. I haven't spotted an obvious workaround, either.

This ticket documents the prospects for the declaration of data kinds, born kind, rather than being data types with kindness thrust upon them. It would be entirely reasonable for the constructors of such things to pack up types as you propose. We're not there yet, but it doesn't look all that problematic.

My eyes are on a greater prize. I would like * to be perfectly sensible type of runtime values, so that the kind you want could exist by promotion as we have it today. Combine that with the mooted notion of pi-type (non-parametric abstraction over the portion of the language that's effectively shared by types and values) and we might get a more direct way to make ad hoc type abstractions than we have with Data.Typeable. The usual forall would remain parametric.

like image 35
pigworker Avatar answered Sep 21 '22 22:09

pigworker