简体   繁体   English

找不到模块“ Control.Monad.Reader”

[英]Could not find module `Control.Monad.Reader'

Today when I tried to compile my code in Geany I got this error 今天,当我尝试在Geany中编译代码时,出现了此错误

Could not find module `Control.Monad.Reader':
  it was found in multiple packages: monads-fd-0.1.0.1 mtl-1.1.0.2
Compilation failed.

I get the same for the Writer monad; 我对Writer monad也是如此; I thought I should remove one of those packages, but I do not want to break other packages, so now what should I do, yesterday everything worked without any problem. 我以为我应该删除其中一个软件包,但我不想破坏其他软件包,所以现在我该怎么办,昨天一切正常。

It looks like you have recently installed monads-fd , perhaps as a dependency of something else you installed. 看来您最近安装了monads-fd ,也许是对您安装的其他产品的依赖。 Both monads-fd and mtl packages contain the module Control.Monad.Reader , so GHC doesn't know which one to use when you compile some code that imports it. monads-fdmtl软件包都包含模块Control.Monad.Reader ,因此,GHC在编译某些导入代码时不知道要使用哪个模块。 You need to resolve the ambiguity somehow: 您需要以某种方式解决歧义:

  • If you are using GHC or GHCi directly 如果您直接使用GHC或GHCi
    • either use a -hide-package <package> flag on the command line to hide one of the packages, or 在命令行上使用-hide-package <package>标志来隐藏其中一个程序包,或者
    • hide the package by default using ghc-pkg hide <package> . 默认使用ghc-pkg hide <package>隐藏该软件包。 You may need to use ghc-pkg --user hide <package> if the package was installed in your home directory (the default on some platforms). 如果软件包安装在主目录中(某些平台上的默认设置),则可能需要使用ghc-pkg --user hide <package>
  • You can use Cabal, and say exactly which one of the conflicting packages you depend on using the build-depends field in your .cabal file 您可以使用Cabal,并使用.cabal文件中的build-depends字段.cabal您依赖哪个冲突软件包。

I encountered a similar problem recently, and it was suggested that I run ghc-pkg hide {x} where '{x}' is the name of one of those packages. 最近我遇到了类似的问题,建议我运行ghc-pkg hide {x} ,其中“ {x}”是这些软件包之一的名称。 It worked in my situation. 它在我的情况下有效。

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

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