5
私のコントロール下にないライブラリモジュールFoo
があるとしますコントロール文書型シグネチャ
module Foo (Foo, thing) where
data Foo = Foo Int
thing :: Foo
thing = Foo 3
は今、私はFoo
からthing
を輸出し直す自分のライブラリモジュールを、持っていると仮定モジュール。互換性の理由から
module Bar (Foo.thing, getBar) where
import qualified Foo
type Bar = Foo.Foo
getBar :: Bar -> Int
getBar (Foo i) = i
、私はは異なるthing
をエクスポートする必要はありませありません。 Foo.thing
をエクスポートして、Foo
とBar
の両方のモジュールをインポートすると、同じthing
が得られ、名前の衝突は発生しません。
ここで、Bar
を使用する第3のモジュールがあるとします。
module Main where
import Bar
ghciに3を読み込みましょう。代わりGHCiのモジュールBar
でthing
はFoo.Foo
型を持つことを示すhaddocksの
[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
を入力した状態たいです。異なるthing
をエクスポートせずにこれを実行する方法はありますか?
ユーザーが両方のモジュールをインポートすると、待ち時間がありません。 –
@GabrielGonzalez 3番目のファイルに 'import Foo'を追加してみてください!両方とも輸入されている場合、ghciに 'Foo'より' Bar'を優先させるように依頼したいと思います。 –
WOW!この機能はどれくらいの期間利用可能でしたか?これはすべての変更です。 –