我在Typeable1
为 Haskell 中的日期结构派生实例时遇到问题。
这是我的代码:
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
import Data.Typeable (Typeable,Typeable1)
newtype FooM m a = Foo { unFoo :: (a -> Bar m) -> Bar m }
newtype Bar m = Atom (m (Maybe (Bar m)))
type Baz m = Waldo (FooM m ())
type Waldo a = a
data Qux m = Qux {
baz :: Baz m
, num :: Int
} -- deriving Typeable1 [1]
-- deriving instance Typeable1 Qux [2]
取消注释第一条评论 [1] 会出现此错误:
Cannot derive well-kinded instance of form `Typeable1 (Qux ...)'
Class `Typeable1' expects an argument of kind `* -> *'
In the data type declaration for `Qux'
取消注释 [2] 会出现此错误:
Kind mis-match
The first argument of `Typeable1' should have kind `* -> *',
but `Qux' has kind `(* -> *) -> *'
In the stand-alone deriving instance for `Typeable1 Qux'
我的问题是:请问如何添加Typeable
/Typeable1
实例Qux
?