GHC existentially quantified singleton
I'm using GHC 7.10 and the singletons
package. There's a GADT named SomeSing in this library that allows you to existentially quantify a singleton. It's definition looks like this:
data SomeSing (kproxy :: KProxy k) where
SomeSing :: Sing (a :: k) -> SomeSing ('KProxy :: KProxy k)
And it works great. We can wrap up a singleton with this so that only the kind is known, not the type.
I wanted to create a variant, a similar wrapper that would allow me to wrap up a singleton and the result of a type function applied to it:
data SomeSingWith (kproxy :: KProxy k) (f :: TyFun k n -> *) where
SomeSingWith :: Sing (a :: k) -> Apply g a -> SomeSingWith ('KProxy :: KProxy k) g
However, I get this error:
Data constructor ‘SomeSingWith’ cannot be GADT-like in its *kind* arguments
SomeSingWith :: forall (k :: BOX) (g :: TyFun k * -> *) (a :: k).
Sing a -> Apply g a -> SomeSingWith 'KProxy g
In the definition of data constructor ‘SomeSingWith’
In the data declaration for ‘SomeSingWith’
What does this mean? And can it be fixed, or is what I'm doing impossible in GHC?
I figured it out. The second argument of TyFun
needs to be kinded *
instead of being allowed to be any arbitrary kind. This makes sense. However, the error message associated with the mistake is not helpful.
data SomeSingWith (kproxy :: KProxy k) (f :: TyFun k * -> *) where
SomeSingWith :: Sing (a :: k) -> Apply g a -> SomeSingWith ('KProxy :: KProxy k) g
链接地址: http://www.djcxy.com/p/43452.html
上一篇: 具有单一严格字段的存在性数据类型
下一篇: GHC存在量化的单身人士