导入语法"import" cryptonite"中带引号的字符串有什么作用? Crypto.Hash`是什么意思? [英] What does a quoted string in the import syntax `import "cryptonite" Crypto.Hash` mean?
问题描述
如标题中所述.有一个代码库,我在其中看到了以下语法
As stated in the title. There is a codebase, where I have seen the following syntax
import "cryptonite" Crypto.Hash
(Context, Digest, SHA256, hash, hashFinalize, hashInit,
hashUpdate)
This syntax doesn't seem to be mentioned on haskell wiki on imports.
"cryptonite"
字符串在这里做什么?
What does the "cryptonite"
string do here?
此语法从何而来?
这是Haskell2010的一部分吗?如果是,它是否在语言报告中提到?
Is is part of Haskell2010 and if it is so where in the language report is it mentioned?
推荐答案
使用
通过PackageImports扩展,GHC允许导入声明以
通过模块打算使用的软件包名称来限定
从进口.例如:
With the PackageImports extension, GHC allows import declarations to
be qualified by the package name that the module is intended to be
imported from. For example: 将导入模块 would import the module 特殊的软件包名称,可以用来指代当前的
软件包正在构建. The special package name this can be used to refer to the current
package being built. 偶尔会出现两个程序包导出具有相同名称的模块的情况.例如, It occasionally happens that two packages export a module with the same name. For example both 据我所知,这不是标准的Haskell(在某种意义上,其他Haskell编译器没有没有支持此功能,似乎 not 在 Haskell 2010报告的导入声明部分),但是是格拉斯哥Haskell编译器扩展.当然,其他编译器也可以支持此功能,但是没有此扩展名的编译器仍然可以正确地称自己为"Haskell编译器".为了激活此扩展,您需要使用 This is to to the best of my knowledge not standard Haskell (in the sense that other Haskell compilers do not have to support this, it seems not specified in the import statement section of the Haskell 2010 report), but a Glasgow Haskell compiler extension. Of course other compilers can support this as well, but a compiler without this extension, can still rightfully call itself a "Haskell compiler". In order to activate this extension, you need to compile with the 这是一个 dynamic 标志,因此也可以在Haskell源文件的编译指示"中指定. This is a dynamic flag, and thus can be specified in the "pragma" of a Haskell source file as well. 这篇关于导入语法"import" cryptonite"中带引号的字符串有什么作用? Crypto.Hash`是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
import "network" Network.Socket
Network.Socket
从软件包network
(任何版本)中获取.这可能用来
当多个模块提供相同的模块时,可以消除导入的歧义
软件包,或者同时存在于当前正在构建的软件包和
外部包装.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.hashmap
和 unordered-containers
导出 cryptonite
需要使用.hashmap
and unordered-containers
export Data.HashSet
. If both packages are installed, we want to disambiguate between the different packages. With this type of import, the author thus specifies that the Crypto.Hash
module of the cryptonite
needs to be used.-XPackageImports
扩展进行编译:-XPackageImports
extension:ghc -XPackageImports main.hs