将文件传递给 GHCi 并在命令行上接收输出?

发布于 2024-10-11 17:24:30 字数 180 浏览 7 评论 0原文

在 Python 中,我们可以这么说:

python script.py

从命令行接收 script.py 的内联输出。是否可以使用 Haskell 的 GHCi 来做到这一点?基本上我想知道是否有一种方法可以从命令行运行 Haskell 程序而无需编译,也无需用户输入解释器。

In Python one can say this:

python script.py

from the command line and receive script.py's output inlined. Is it possible to do this with Haskell's GHCi? Basically I'm wondering if there's a way to run a Haskell program from the command line without compiling and without the user entering the interpreter.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青朷 2024-10-18 17:24:30

runghc 就是您要寻找的。从它的联机帮助页来看:

runghc 被认为是非交互式解释器,并且是 Glasgow 的一部分
哈斯克尔编译器。 runghc 是一个编译器,它会自动运行其结果
结束。

编辑:Ubuntu 提供了一个名为 runhaskell 的符号链接,但它可能不是标准的。

runghc is what you're looking for. From its manpage:

runghc is considered a non-interactive interpreter and part of The Glasgow
Haskell Compiler. runghc is a compiler that automatically runs its results at
the end.

Edit: Ubuntu provides a symlink called runhaskell, but it might not be standard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文