控制重新导出功能的文档类型签名

时间:2012-08-24 15:50:28

标签: haskell module export ghci haddock

假设有一个不受我控制的库模块Foo

module Foo (Foo, thing) where
data Foo = Foo Int
thing :: Foo
thing = Foo 3

现在假设我有自己的库模块,它从thing模块重新导出Foo

module Bar (Foo.thing, getBar) where
import qualified Foo
type Bar = Foo.Foo
getBar :: Bar -> Int
getBar (Foo i) = i

出于兼容性原因,我想要导出不同的thing。我想确保导出Foo.thing,这样如果用户同时导入FooBar模块,它们将获得相同的thing并且不会有名字冲突。

现在假设我们有第三个使用Bar的模块。

module Main where
import Bar

让我们将第三个加载到ghci。

[1 of 3] Compiling Foo              ( Foo.hs, interpreted )
[2 of 3] Compiling Bar              ( Bar.hs, interpreted )
[3 of 3] Compiling Main             ( test.hs, interpreted )
Ok, modules loaded: Main, Bar, Foo.
ghci> :t thing
thing :: Foo.Foo
ghci> :t getBar
getBar :: Bar -> Int
ghci> getBar thing
3
ghci> :info Bar
type Bar = Foo.Foo  -- Defined at Bar.hs:3:6-8

而不是ghci和指示模块thing中的Bar具有类型Foo.Foo的黑线鳕,而不是说明thing类型Bar }。有没有办法在不导出其他thing的情况下实现这一目标?

1 个答案:

答案 0 :(得分:0)

除非我听到相反的证据,否则答案似乎是:你不能

相关问题