简体   繁体   English

Snap Monad,LiftIO和ghc 7.4.1

[英]Snap Monad, LiftIO and ghc 7.4.1

I'm trying to get some code that was working in ghc 7.0.4 work with 7.4.1. 我正在尝试使用ghc 7.0.4和7.4.1一起工作的一些代码。

It appears to me that old way of accessing IO from inside the Snap moand no longer typechecks. 在我看来,从Snap内部访问IO的旧方法不再进行类型检查。

In ghc 7.0.4, the documented way of accessing IO compiles. 在ghc 7.0.4中,有文献记载的IO编译方式。

a :: Snap ()
a = liftIO fireTheMissiles

http://hackage.haskell.org/packages/archive/snap-core/0.8.1/doc/html/Snap-Core.html http://hackage.haskell.org/packages/archive/snap-core/0.8.1/doc/html/Snap-Core.html

In GHC 7.4.1, 在GHC 7.4.1中,

No instance for (MonadIO Snap)
  arising from a use of `liftIO'
Possible fix: add an instance declaration for (MonadIO Snap)

I'm curious what an attractive work around would be. 我很好奇周围会发生什么有吸引力的工作。

My guess would be that you have conflicting versions of some package (likely transformers ). 我的猜测是您的某些软件包的版本有冲突(可能是transformers )。 Snap is likely built against a different version (perhaps 0.2.2) while you're trying to use version 0.3. 当您尝试使用版本0.3时,可能会针对其他版本(可能是0.2.2)构建了Snap。 As a result, there's no instance for the MonadIO that you have in scope (from 0.3). 结果,您的范围内没有MonadIO实例(从0.3开始)。 This is just a guess, but I've seen the same thing occur a number of times. 这只是一个猜测,但是我已经看到同一件事发生了很多次。

One of the easiest ways to avoid this situation is to cabalize your code. 避免这种情况的最简单方法之一是使代码无效化。 cabal will warn you if you try to use different versions of the same package. 如果您尝试使用同一软件包的不同版本,cabal会警告您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM