gpt4 book ai didi

haskell - 从模块中导出类型运算符

转载 作者:行者123 更新时间:2023-12-04 01:59:04 24 4
gpt4 key购买 nike

你如何导出类型运算符?考虑到它们可能与普通运算符发生冲突,如果可能的话,必须有一个特殊的语法。

最佳答案

我在 7.4.4 of the GHC User's Guide 部分找到了答案,其中指出:

There is now some potential ambiguity in import and export lists; for example if you write import M( (+) ) do you mean the function (+) or the type constructor (+)? The default is the former, but with -XExplicitNamespaces (which is implied by -XExplicitTypeOperators) GHC allows you to specify the latter by preceding it with the keyword type, thus:

import M( type (+) )

虽然看起来您实际上不需要指定 -XExplicitNamespaces ,也许 -XExplicitTypeOperators是一个错字,意思是 -XTypeOperators .一些更多的经验证据:
★ → :set -XExplicitTypeOperators
Some flags have not been recognized: -XExplicitTypeOperators

关于haskell - 从模块中导出类型运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29161217/

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