如果两个模块共享相同的名称,该怎么办? [英] What should I do if two modules share the same name?
问题描述
我有两个提供相同名称模块的软件包.当我尝试加载模块时出现错误
I have two packages that provide modules with the same name. When I try to load the module I get an error
用于....的歧义接口:在多个软件包中被发现.
Ambiguous interface for ....: It was found in multiple packages.
我应该怎么做才能解决这个问题?
What should I do to resolve this?
具体来说,cryptonite
软件包和crypto-api
软件包都为模块提供了名称Crypto.Random
.如何指定要从哪个包加载模块?
To be specific, both the cryptonite
package and crypto-api
package provide modules with the name Crypto.Random
. How can I specify which package I want to load the module from?
推荐答案
您可以使用PackageImports
语言编译指示,并像下面这样显式地选择您在import语句中表示的软件包:
You can use the PackageImports
language pragma and explicitly pick the package you mean in your import statement like so:
import "cryptonite" Crypto.Random
或者,如果您同时安装了两者,但仅使用了其中之一,则可以显式列出在cabal
文件中使用的依赖项,并通过cabal
进行构建.
Alternatively if you have both installed but are only using one of them, you could explicitly list the dependencies you use in a cabal
file and build via cabal
.
这篇关于如果两个模块共享相同的名称,该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!