ghc-mod期望MonadBaseControl将`StM`关联为newtype而不是`StT`关联类型

时间:2014-12-24 14:31:25

标签: haskell monad-transformers type-families ghc-mod

我从沙箱中的Hackage安装最新的ghc-mod(5.2.1.1)时遇到此错误:

[15 of 38] Compiling Language.Haskell.GhcMod.CabalConfig ( Language/Haskell/GhcMod/CabalConfig.hs, dist/dist-sandbox-94286619/build/Language/Haskell/GhcMod/CabalConfig.o )
[16 of 38] Compiling Language.Haskell.GhcMod.CabalApi ( Language/Haskell/GhcMod/CabalApi.hs, dist/dist-sandbox-94286619/build/Language/Haskell/GhcMod/CabalApi.o )
[17 of 38] Compiling Language.Haskell.GhcMod.Cradle ( Language/Haskell/GhcMod/Cradle.hs, dist/dist-sandbox-94286619/build/Language/Haskell/GhcMod/Cradle.o )
[18 of 38] Compiling Language.Haskell.GhcMod.Monad ( Language/Haskell/GhcMod/Monad.hs, dist/dist-sandbox-94286619/build/Language/Haskell/GhcMod/Monad.o )

Language/Haskell/GhcMod/Monad.hs:370:5:
    Wrong category of family instance; declaration was for a type synonym
    In the newtype instance declaration for ‘StM’
    In the instance declaration for ‘MonadBaseControl IO (GhcModT m)’
cabal: Error: some packages failed to install:
ghc-mod-5.2.1.1 failed during the building phase. The exception was:
ExitFailure 1

我之前从未见过这个错误,所以我去挖掘。在Language/Haskell/GhcMod/Monad.hs中,当然它正在做一些有趣的事情:

instance (MonadBaseControl IO m) => MonadBaseControl IO (GhcModT m) where
    newtype StM (GhcModT m) a = StGhcMod {
          unStGhcMod :: StM (StateT GhcModState
                              (ErrorT GhcModError
                                (JournalT GhcModLog
                                  (ReaderT GhcModEnv m) ) ) ) a } 
    liftBaseWith f = GhcModT . liftBaseWith $ \runInBase ->
        f $ liftM StGhcMod . runInBase . unGhcModT

如果您在Hackage上查看at monad-control,那么就没有 StM关联的新类型,但只有StT关联类型。

除非这里有其他类型的诡计,否则我很难过。这将如何解决?谢谢。

1 个答案:

答案 0 :(得分:3)

抓住这个,我的眼睛在愚弄我。我的错误,因为monad-control-1.x,MonadControl有一个关联的类型而不是关联的数据类型,如here所述。