找不到模块“Control.Monad.Reader” [英] Could not find module `Control.Monad.Reader'
问题描述
今天当我试图在Geany中编译我的代码时,我得到了这个错误。
无法找到模块Control.Monad。 Reader':
它被发现在多个软件包中:monads -fd-0.1.0.1 mtl-1.1.0.2
编译失败。
我为Writer monad获得了相同的结果;我以为我应该删除其中一个软件包,但我不想打破其他软件包,所以现在我该怎么办,昨天一切正常,没有任何问题。
看起来您最近安装了 monads-fd
,可能是您安装的其他东西的依赖关系。 monads-fd
和 mtl
包都包含模块 Control.Monad.Reader
,所以当你编译一些导入它的代码时,GHC不知道使用哪一个。您需要以某种方式解决歧义:
- 如果您直接使用GHC或GHCi
- 在命令行上使用
-hide-package< package>
标志隐藏其中一个包,或者
- 默认使用
ghc-pkg hide< package>
隐藏软件包。如果软件包安装在您的主目录(某些平台上的默认设置)中,您可能需要使用ghc-pkg --user hide< package>
。
- 默认使用
- 在命令行上使用
- 您可以使用Cabal,并确切地说明您使用
build-depends $>所依赖的冲突包您的
.cabal
文件中的c $ c>字段
Today when I tried to compile my code in Geany I got this error
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; 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. 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. You need to resolve the ambiguity somehow:
- If you are using GHC or GHCi directly
- either use a
-hide-package <package>
flag on the command line to hide one of the packages, or - hide the package by default using
ghc-pkg hide <package>
. You may need to useghc-pkg --user hide <package>
if the package was installed in your home directory (the default on some platforms).
- either use a
- 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
这篇关于找不到模块“Control.Monad.Reader”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!