Cabal repl 无法:在库中加载模块

Cabal repl can't :load module in library

您好,我在 cabal 文件中有以下模块:

library task1-lib
    exposed-modules:
        Interpreter,
        Parser
    build-depends: 
        base ^>=4.14.3.0,
        containers,
        mtl,
        parsec
    ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wno-unused-top-binds -Wno-orphans -Wno-type-defaults

    hs-source-dirs:   
        task1/lib
    default-language: Haskell2010

executable task1
    main-is:          Main.hs
    ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wno-unused-top-binds -Wno-orphans -Wno-type-defaults

    build-depends:    
        base ^>=4.14.3.0
    hs-source-dirs:   task1
    default-language: Haskell2010

当我这样做时:

cabal repl
...
GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help
[1 of 2] Compiling Interpreter      ( task1/lib/Interpreter.hs, interpreted )
[2 of 2] Compiling Parser           ( task1/lib/Parser.hs, interpreted )
Ok, two modules loaded.
> :l Parser

我收到以下错误:

<no location info>: error: [-Wmissing-home-modules, -Werror=missing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Interpreter

问题

当我想加载单个文件以在 repl 中试验该模块的功能时该怎么办?

同样,当我尝试命令 cabal repl task1-lib 时,也会发生同样的情况。

编辑:

通过在 -Werror 之后添加 -Wwarn=missing-home-modules,可以通过以下方式修改 cabal。这仍然适用于所有警告的 -Werror 而不是仍然是警告的 missing-home-modules 错误,并且可以 :load a module in repl then.

library task1-lib
    exposed-modules:
        Interpreter,
        Parser
    build-depends: 
        base ^>=4.14.3.0,
        containers,
        mtl,
        parsec
    ghc-options: -Wall -Werror -Wwarn=missing-home-modules -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wno-unused-top-binds -Wno-orphans -Wno-type-defaults

    hs-source-dirs:   
        task1/lib
    default-language: Haskell2010

executable task1
    main-is:          Main.hs
    ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wno-unused-top-binds -Wno-orphans -Wno-type-defaults

    build-depends:    
        base ^>=4.14.3.0
    hs-source-dirs:   task1
    default-language: Haskell2010

import enables only functions that are exported by the module

不要取消 :loadimport,请尝试使用 :module + *NameOfTheModule

根据 :module 的文档:

:module supports the * modifier on modules, which opens the full top-level scope of a module, rather than just its exports.

这不能用普通的 import 声明来完成,它的行为很像 import 在常规的 Haskell 程序中。