gpt4 book ai didi

haskell - 导入 "base"系统.IO

转载 作者:行者123 更新时间:2023-12-02 17:51:41 24 4
gpt4 key购买 nike

packages-haskell2010/System/IO.hs我们有以下行:

import "base" System.IO hiding (openFile, hWaitForInput)

这种形式的导入(后面跟一个字符串,然后是模块名称)没有记录在 Import 中。 。我假设字符串(在本例中为“base”)仅指目录是否正确?

最佳答案

该字符串指的是一个包,因为这是 package-qualified import 。该扩展由

启用
{-# LANGUAGE PackageImports #-}

可以使用它来包含指定包中的给定模块。在你的情况下,它将导入 System.IO来自包“base”:

With the -XPackageImports flag, GHC allows import declarations to be qualified by the package name that the module is intended to be imported from. For example:

import "network" Network.Socket

would import the module Network.Socket from the package network (any version). This may be used to disambiguate an import when the same module is available from multiple packages, or is present in both the current package being built and an external package.

如果您想知道系统上有哪些软件包,请使用 ghc-pkg list 。请注意,您可能需要 ghc-pkg recache如果您中止了 cabal 中软件包的安装,并且 recache可能需要管理员权限(取决于您的平台)。

关于haskell - 导入 "base"系统.IO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21645941/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com