RunGHC 给出 "target ‘prog’ is not a module name or a source file"
RunGHC gives "target ‘prog’ is not a module name or a source file"
我刚刚开始研究 Real World Haskell,并且刚刚开始学习第一个示例程序。我在 Raspberry Pi、raspbian 精简版上 运行ning GHC。程序 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
我做错了什么?
您 post 的错误提示文件 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。我尝试的第一个来自 this post,它在 GHCI 中运行良好,但在 GHCI 之外表现不佳。
幸运的是,从那时起,更密切地参与 GHC 开发的人们对使其与 ARM 和 RPi 兼容产生了兴趣,并创建了一个更健康的安装过程(尽管仍未完全包管理)here。
重新安装GHC后,程序运行正常。
我刚刚开始研究 Real World Haskell,并且刚刚开始学习第一个示例程序。我在 Raspberry Pi、raspbian 精简版上 运行ning GHC。程序 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
我做错了什么?
您 post 的错误提示文件 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。我尝试的第一个来自 this post,它在 GHCI 中运行良好,但在 GHCI 之外表现不佳。
幸运的是,从那时起,更密切地参与 GHC 开发的人们对使其与 ARM 和 RPi 兼容产生了兴趣,并创建了一个更健康的安装过程(尽管仍未完全包管理)here。 重新安装GHC后,程序运行正常。