在 GHCi 中,':module' 和 'import' 有什么区别?
In GHCi, what is the difference between ':module' and 'import'?
在 GHCi 中,似乎有两种方法可以包含已安装的模块:
Prelude> :module Database.HDBC
Prelude Database.HDBC>
和
Prelude> import Database.HDBC
Prelude Database.HDBC>
这些有什么区别吗?如果不是,为什么重复命令?
我一直使用 import
,现在我注意到 :module
用于 Real World Haskell's databases chapter。
来自GHCi docs:
The :module
command provides a way to do two things that cannot be
done with ordinary import
declarations:
:module
supports the *
modifier on modules, which opens the full top-level scope of a module, rather than just its exports.
- Imports can be removed from the context, using the syntax
:module -M
. The import
syntax is cumulative (as in a Haskell module), so this is the only way to subtract from the scope.
在 GHCi 中,似乎有两种方法可以包含已安装的模块:
Prelude> :module Database.HDBC
Prelude Database.HDBC>
和
Prelude> import Database.HDBC
Prelude Database.HDBC>
这些有什么区别吗?如果不是,为什么重复命令?
我一直使用 import
,现在我注意到 :module
用于 Real World Haskell's databases chapter。
来自GHCi docs:
The
:module
command provides a way to do two things that cannot be done with ordinaryimport
declarations:
:module
supports the*
modifier on modules, which opens the full top-level scope of a module, rather than just its exports.- Imports can be removed from the context, using the syntax
:module -M
. Theimport
syntax is cumulative (as in a Haskell module), so this is the only way to subtract from the scope.