【发布时间】:2014-05-31 14:52:47
【问题描述】:
如果我们查看The random package 的来源,我们有一个文件Random.hs。由于 CPP 扩展,必须通过以下命令调用 ghci:
ghci -cpp Random.hs
另外一个可以做:
ghci -cpp
然后从 ghci 内部:
Prelude GOA> :load Random
[1 of 1] Compiling System.Random ( Random.hs, interpreted )
Ok, modules loaded: System.Random.
如果我使用 Emacs Inferior Haskell 模式 (Emacs/Inferior Haskell processes) 并且我有 来源:
module Main where
import System.Random
gen = (random (mkStdGen 0)) :: (Bool,StdGen)
mymult :: Int -> Int
mymult x = 2 * x
main = do
print $ mymult 5
然后在输入 emacs 命令时:
C-c C-l
inferior-haskell-load-file,ghci 在 emacs 的子窗口中打开。但是,如果在此窗口中输入 load Random.hs,则会收到错误消息:
*Main GOA> :load Random.hs
Random.hs:1:2: lexical error at character 'i'
Failed, modules loaded: none.
如何在考虑 cpp 扩展的情况下加载 Random.hs?或者,我如何修改haskell-mode/inf-haskell.el,以便在键入C-c C-l 时使用-cpp 选项调用ghci,以便可以无错误地执行命令:load Random.hs?
【问题讨论】:
-
当我执行
:load Random.hs时,我没有收到错误消息。在您提供的示例代码中,我看不出您需要-cpp作为ghci的选项的任何原因。在没有选项本身的情况下调用它对我有用。 -
@Sibi 你的意思是你可以在hackage.haskell.org/package/random的zip文件中加载
Random.hs而不需要任何cpp选项?