I've been toying around with -XDataKinds
recently, and was wondering why Foo
below won't be automatically promoted:
{-# LANGUAGE
GADTs
, DataKinds
, KindSignatures #-}
import Data.HList
data Foo a where
Foo :: Bar a =>
a -> Foo a
data Baz where
Baz :: (a ~ HList (l :: [Foo *])) =>
a -> Baz
That is, Baz
is a heterogenous list of Foo a
's, where a
is constrained by Bar
.
Is there a way to manually create a promoted version of this data type? How would I go about doing so? Can kinds be declared? Could I make a dummy Haskell98 version of Foo
, and separate it into a module or something? Ideally I'd like to keep the constraint context, but I don't think there's a Constraint
sort. Any ideas would be very helpful!
Foo
the only inhabitant of it. – Unbonnet'[]
instead, but again I don't know enough aboutDataKinds
to tell you why this version works in particular. – BerniecebernierFoo
is unpromotable, since GADTs in general are unpromotable (in this specific case, it is because of the constraint). If you try:kind! 'Foo
in ghci, you will see this.Foo
refers to the type constructorFoo
, not the data constructor, when used inBaz
. AlthoughBaz
is a very boring type becauseHList ('[Foo b])
is essentially justFoo b
, andb
is existentially quantified soBaz
is equivalent todata Baz = forall a . Bar a => Baz a
. I don't know if this is what you want, but somehow I doubt it. – Hedve'[Foo b]
was a singleton. Crud. Back to the drawing board. – UnbonnetHList
and a class which recurses through the list and does whatever to each element. – Hedvel
, like in my question, but make it higher kinded, then supply a parameterb
and bind it toFooLike a
. Phew! @Berniecebernier Would you like to issue the answer? – Unbonnet