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の両方をインポートした場合、それらが同じになり、名前の衝突が発生しないように、をエクスポートすることを確認したいと思います。FooBarthing
を使用する 3 番目のモジュールがあるとしますBar。
module Main where
import Bar
3番目を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
thingモジュールBarに type があることを示す ghci と haddocks の代わりに、 type があると述べたいFoo.Fooと思います。別のものをエクスポートせずにこれを実現する方法はありますか?thingBarthing