Haskell重新导出模块除了在模块内定义的所有内容 [英] Haskell re-export module in addition to everything defined within module

查看:137
本文介绍了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 并导出 测试,而不需要明确写出中定义的每个函数测试

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆