2012-07-15 69 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問題消失。

相關問題