I noticed with PolyKinds
and DataKinds
the following compiles fine:
data Pair a b
data Test = Test
type Test2 = Pair 'Test 'Test
However:
type Test3 = ('Test, 'Test)
fails, presumably as (,)
is not kind polymorphic, which makes sense as it makes values out of it's type arguments and you can't make values of types which are not of kind *
.
Is there a library that has kind polymorphic tuples (to save me reinventing the wheel)?
I do realise that that unlike real tuples, kind polymorphic tuples will only exist on the type level, but that's all I need for my purposes.
If you are already using DataKinds
, you should just use the promoted version of built-in tuple constructor, as opposed to the type constructor:
type Test3 = '( 'Test, 'Test)
This has kind (Test, Test)
.
Note there must be a space between (
and '
; '('Test, 'Test)
is a syntax error (a necessary edge case in the parser).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With