Sorry for the very basic question: In GHCi, is there a difference between import Library.Name
and :m +Library.Name
? They seem equivalent, but I ass
You would include import
in the source code, which is more general, whereas :m
is a ghci - specific command (for convenience).
You can use ghci> :m + Module1 ... ModuleN
to load multiple modules. Use -
instead of +
to unload the module. Because ghci
is interactive, I'd stick to :m
, unless your workflow is rather: edit your .hs
file, save it, and reload it. Then the import
would be more suitable (and has more features e.g. qualified imports).
The import
directive would also work if you later decide to compile the program using for example ghc
. You can selectively import only specific functions: import Data.List (sort)
would import only sort, so is pollutes the namespace less.