在编译项目的模块之后如何让`cabal repl`读取`.ghci` *?

时间:2014-07-23 02:33:20

标签: haskell cabal ghci

我有

:m +Control.Monad System.Random.MWC NW.Affix

在我项目的根目录中的.ghci文件中。我想用NW.Affix加载cabal repl(我的项目中的一个模块),但它会立即失败:

Preprocessing executable 'netherworld' for netherworld-0.0.0.0...
GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.3.1 ... linking ... done.
Loading package text-1.1.1.3 ... linking ... done.
Loading package parsec-3.1.5 ... linking ... done.
Loading package primitive-0.5.3.0 ... linking ... done.
Loading package old-locale-1.0.0.6 ... linking ... done.
Loading package time-1.4.2 ... linking ... done.
Loading package vector-0.10.11.0 ... linking ... done.
Loading package mwc-random-0.13.1.2 ... linking ... done.
Loading package monads-tf-0.1.0.2 ... linking ... done.
Loading package filepath-1.3.0.2 ... linking ... done.
Loading package byteable-0.1.1 ... linking ... done.
Loading package cryptohash-0.11.6 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.

<no location info>:
    Could not find module ‘NW.Affix’
    It is not a module in the current program, or in any known package.

在这样失败后,它很高兴地编译我的模块,如下:

[ 1 of 14] Compiling NW.Util          ( src/NW/Util.hs, interpreted )
[ 2 of 14] Compiling NW.Stats         ( src/NW/Stats.hs, interpreted )
[ 3 of 14] Compiling NW.Monster       ( src/NW/Monster.hs, interpreted )
[ 4 of 14] Compiling NW.Random        ( src/NW/Random.hs, interpreted )
[ 5 of 14] Compiling NW.Map           ( src/NW/Map.hs, interpreted )
[ 6 of 14] Compiling NW.Player        ( src/NW/Player.hs, interpreted )
[ 7 of 14] Compiling NW.Error         ( src/NW/Error.hs, interpreted )
[ 8 of 14] Compiling NW.Effect        ( src/NW/Effect.hs, interpreted )
[ 9 of 14] Compiling NW.Config        ( src/NW/Config.hs, interpreted )
[10 of 14] Compiling NW.Affix         ( src/NW/Affix.hs, interpreted )
[11 of 14] Compiling NW.Item          ( src/NW/Item.hs, interpreted )
[12 of 14] Compiling NW.State         ( src/NW/State.hs, interpreted )
[13 of 14] Compiling NW.Battle        ( src/NW/Battle.hs, interpreted )
[14 of 14] Compiling Main             ( src/main.hs, interpreted )
Ok, modules loaded: NW.Affix, Main, NW.Battle, NW.Config, NW.Item, NW.Error, NW.Map, NW.Player, NW.Random, NW.State, NW.Stats, NW.Monster, NW.Effect, NW.Util.

目前的工作方式是在我的.ghci内容完成初始化之后将其复制粘贴到cabal repl。不过,有没有办法推迟cabal repl.ghci文件中读取 之后完成编译我的项目模块?

1 个答案:

答案 0 :(得分:1)

好吧,我还没有真正理解它,但是“解决方法”(如果你可以称之为)就是将:m行拆分为:m以便为cabal安装的包打破和:l为你自己的。

所以在我的情况下,我刚刚改变了

:m +Control.Monad System.Random.MWC NW.Affix

:l NW.Item
:m +Control.Monad System.Random.MWC
我的.ghcicabal repl中的

按预期工作。但它似乎有点迂回......我的意思是,如果在加载后复制/粘贴.ghci使其无论如何都能正常工作,为什么需要这个:m:l区别?