如何在 cabal repl 中自动加载导入?

How to load imports automatically in cabal repl?

我的印象是,直到最近 cabal repl 才自动从当前加载的文件中导入所有导入内容。也就是说,如果我有一个文件 src/Main.hs:

module Main where

import qualified Data.Vector as V

main = putStrLn "foo"

我会用 :l src/Main.hscabal repl 中加载它,V 无需任何进一步的工作就可以使用。

我相信这种行为在更改为 ghc/ghci 7.10 期间发生了变化,但我不确定。有没有什么选项可以让我把它改回以前的样子?

编辑: 碰巧我已经编译了模块,这是问题的一部分。请参阅下面的 Ørjan Johansens 评论。

来自GHC User's Guide

The syntax in the prompt *module indicates that it is the full top-level scope of module that is contributing to the scope for expressions typed at the prompt. Without the *, just the exports of the module are visible.

NOTE: for technical reasons, GHCi can only support the *-form for modules that are interpreted. Compiled modules and package modules can only contribute their exports to the current scope. To ensure that GHCi loads the interpreted version of a module, add the * when loading the module, e.g. :load *M.

也就是说加载的时候在模块名前加一个*