润康提供"target ‘prog’ is not a module name or a source file"



我刚刚开始通过现实世界的Haskell工作,并且刚刚进入第一个示例程序。我在Raspberry Pi上运行GHC,Raspbian lite。该计划,WC.hs,是

main = interact wordCount
where wordCount input = show (length (lines input)) ++ "n"

然后您调用一个看起来像 CSV 文本文件

Paris, France
Ulm, Germany
Auxerre, France
Brunswick, Germany

当我尝试按照书中的禁止运行该程序时,

runghc WC < quux.txt

我收到错误

target ‘prog’ is not a module name or a source file

我在这里做错了什么?

您发布的错误表明文件WC.hs不在运行runghc时您所在的目录中。 命令序列在正常系统上工作:

% cat <<EOF >WC.hs
heredoc> main = interact wordCount
where wordCount input = show (length (lines input)) ++ "n"
heredoc> EOF
% cat <<EOF >quux.txt
heredoc> Paris, France
Ulm, Germany
Auxerre, France
Brunswick, Germany
heredoc> EOF
% runghc WC.hs < quux.txt
Loaded package environment from /private/tmp/.ghc.environment.x86_64-darwin-8.6.4
4

因此,请仔细检查您的目录和文件名。

看来我的GHC安装并不完美。由于RPi的ARM架构,以及他们为保持Raspbian向后兼容而做出的一些奇怪的决定,您目前必须采取变通方法来安装GHC。我第一次尝试的是这篇文章,它在GHCI中效果很好,但在它之外表现不佳。

幸运的是,从那时起,与GHC开发关系密切的人对使其与ARM和RPi兼容产生了兴趣,并在这里创建了一个更健康的安装过程(尽管仍然没有完全包管理(。 重新安装GHC后,该程序正常工作。

相关内容

最新更新