次のサンプルモジュールを使用します。
module Exp ( initial, myval ) where
data State = State { i :: Int }
initial = State { i = 123 }
myval st = i st
モジュールをGHCIにロードした後、 State
と i
の名前もエクスポートされていることがわかります。私はそのタイプを手に入れて使うことができます。
初期
(ブラックボックス)と myval
だけをエクスポートするようにエクスポートを制限するにはどうすればよいですか?
ベストアンサー
State
and i
are not exported, but if
you load an interpreted module in ghci, then all top-level
definitions of that module are in scope. To hide what you didn’t
export from ghci, compile the module and load the compiled module,
:l Exp
resp ghci Exp
. Then only the
exported entities are available.