Haskell用额外的导入模块导出当前模块 [英] Haskell export current module with additional imported module
问题描述
是否可以在Haskell中编写一个模块,除了导出可见内的所有内容外,它还重新导出模块?
Is it possible to write a module in Haskell, which re-exports a module in addition to exporting everything visible inside?
让考虑以下模块:
Lets consider following module:
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
并导出所有内容 c $ c> Test 而不需要显式地编写 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
?
推荐答案
有一个简单的解决方案,只需将模块导出即可m模块:
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屋!