Haskell 使用额外的导入模块导出当前模块 [英] Haskell export current module with additional imported module
本文介绍了Haskell 使用额外的导入模块导出当前模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 Haskell 中编写一个模块,除了导出所有可见里面的内容外,还重新导出一个模块?
Is it possible to write a module in Haskell, which re-exports a module in addition to exporting everything visible inside?
让我们考虑以下模块:
module Test where
import A
f x = x
这个模块导出里面的所有定义,所以它导出f
但不会重新导出从A
导入的任何东西.
This module exports everything defined inside, so it exports f
but does not re-export anything imported from A
.
另一方面,如果我想重新导出模块A
:
On the other hand, if I want to re-export the module A
:
module Test (
module A,
f
) where
import A
f x = x
有没有办法重新导出A
并导出Test
中定义的一切,而无需显式编写 中定义的每个函数>测试
?
Is there a way to re-export A
and export everything defined in Test
without needing to explicitly write every function defined within Test
?
推荐答案
有一个简单的解决方案,直接从模块中导出模块即可:
There is a simple solution, just export the module from the module:
module Test
( module Test
, module A
) where
import Prelude()
import A
f x = x
这篇关于Haskell 使用额外的导入模块导出当前模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文