2012-07-15 67 views
1

我无法为Haskell中的日期结构派生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的实例请问3210?

回答

2

不幸的是,您不能:Typeable层次结构没有任何类型的东西(* -> *) -> *。 GHC开始支持类型多态性后,这可能会在未来某个时间得到修正。

0

看起来,这个问题目前正在考虑ghc票,#5391。所以有可能在GHC 7.6中deriving Typeable问题消失。

相关问题