2013-06-27 3 views
5

をコンパイルしていない私はXFlexibleInstancesを追加する場合は、私にGHC 7.4.2MonadStateインスタンスが<a href="http://book.realworldhaskell.org/read/monad-transformers.html" rel="nofollow noreferrer">http://book.realworldhaskell.org/read/monad-transformers.html</a>からコピーされ、これMonadStateインスタンス

instance (MonadState s m) => MonadState s (MaybeT m) where 
    get = lift get 
    put k = lift (put k) 

との誤差を与え、

Illegal instance declaration for `MonadState s (MaybeT m)' 
    (All instance types must be of the form (T a1 ... an) 
    where a1 ... an are *distinct type variables*, 
    and each type variable appears at most once in the instance head. 
    Use -XFlexibleInstances if you want to disable this.) 
In the instance declaration for `MonadState s (MaybeT m)' 

を与えます代わりにXUndecidableInstancesを追加するように指示されています - 私はここにこれらの拡張が必要ではないと思います。このインスタンスをコンパイルするには?

答えて

5

http://hackage.haskell.org/packages/archive/mtl/latest/doc/html/src/Control-Monad-State-Class.html#MonadStateを見ると、 "offical"実装でも使用されていることがわかりますので、必要と思われます。コメントは、それがこれらのstackoverflowの質問で説明されたカバレッジ条件、に関係していると言う。この場合

、変数sは、右の上に存在しませんfunctonalの依存関係は右から左に行くので、あなたのインスタンスは無効です。 (判読不能の場合)

関連する問題

 関連する問題