我有一个数据类型,我通过ghc 7.4.1中的DataKinds和我想用来进行类型特定操作的给定类型类提升.
data Type = TInt32 | TInt64 | TInt16
class TypeTraits a where
...
Run Code Online (Sandbox Code Playgroud)
然后我尝试创建提升类型的类型类实例,如下所示:
instance TypeTraits TInt32 where
...
Run Code Online (Sandbox Code Playgroud)
我收到以下类型的错误:
Kind mis-match
The first argument of `TypeTraits' should have kind `*',
but `TInt32' has kind `Type'
In the instance declaration for `TypeTraits TInt32'
Run Code Online (Sandbox Code Playgroud)
尝试通过指定'a'的类型来解决这个问题:
class TypeTraits (a :: Type) where
...
Kind mis-match
Expected kind `ArgKind', but `a' has kind `Type'
In the type `a -> String'
In the class declaration for `TypeTraits'
Run Code Online (Sandbox Code Playgroud)