为ghci中的模块相关命令指定包名

发布于 2024-09-27 04:11:25 字数 398 浏览 9 评论 0原文

有没有办法为 ghci 中的 :browse:load:module 命令指定模块的包名称(版本 6.12.x) 1) ?

有些模块名称不明确:

Prelude> :module Control.Monad.Cont

<no location info>:
    Ambiguous module name `Control.Monad.Cont':
      it was found in multiple packages: mtl-1.1.0.2 monads-fd-0.1.0.2

设置 -hide-package 选项是我唯一能做的避免歧义的事情吗?

Is there a way to specify the package name for a module for the :browse, :load or :module commands in ghci (version 6.12.1) ?

Some module names are ambiguous:

Prelude> :module Control.Monad.Cont

<no location info>:
    Ambiguous module name `Control.Monad.Cont':
      it was found in multiple packages: mtl-1.1.0.2 monads-fd-0.1.0.2

Is setting the -hide-package option the only thing I can do to avoid the ambiguity?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岁月打碎记忆 2024-10-04 04:11:25

据我所知,是的。但这不一定是一个大问题,你可以在 ghci 中执行此操作:

Prelude Data.List> :set -hide-package mtl
package flags have changed, resetting and loading new packages...
Prelude> import Control.Monad.Cont
Prelude Control.Monad.Cont> 

GHC-7 更改日志上还有一个行项目让我认为包导入可以在命令行上运行,但事实并非如此似乎还没有(见下文)。更改注释说的是“GHCi 支持的完整导入语法”,我认为它必须排除扩展。

$ ghci-7.0.0.20100924 -XPackageImports
GHCi, version 7.0.0.20100924: http://www.haskell.org/ghc/  :? for help
...
Prelude Data.List> import "mtl" Control.Monad.Cont

<no location info>:
    Ambiguous module name `Control.Monad.Cont':
      it was found in multiple packages: mtl-1.1.1.0 monads-fd-0.1.0.2

As far as I know, yes. But it doesn't have to be a big deal, you can do this inside ghci:

Prelude Data.List> :set -hide-package mtl
package flags have changed, resetting and loading new packages...
Prelude> import Control.Monad.Cont
Prelude Control.Monad.Cont> 

There was also a line-item on GHC-7 change log that made me think package imports would work on the command line, but it doesn't seem to yet (see below). The change comment said something like "full import syntax supported in GHCi", which must exclude extensions I suppose.

$ ghci-7.0.0.20100924 -XPackageImports
GHCi, version 7.0.0.20100924: http://www.haskell.org/ghc/  :? for help
...
Prelude Data.List> import "mtl" Control.Monad.Cont

<no location info>:
    Ambiguous module name `Control.Monad.Cont':
      it was found in multiple packages: mtl-1.1.1.0 monads-fd-0.1.0.2
时光清浅 2024-10-04 04:11:25

设置 -hide-package 选项是我唯一能做的避免歧义的事情吗?

您可以使用ghc-pkg,例如,

$ ghc-pkg hide monads-fd

这就像在每个后续ghc调用上设置-hide-package。通过 Cabal 显式依赖于 monads-fd 的软件包不会受到影响,但其他一切都会受到影响。当心!

Is setting the -hide-package option the only thing I can do to avoid the ambiguity?

You can use ghc-pkg, e.g.

$ ghc-pkg hide monads-fd

This is like setting -hide-package on every subsequent ghc invocation. Packages explicitly depending on monads-fd via Cabal will not be affected, but everything else is. Watch out!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文