gpt4 book ai didi

haskell - 在Windows中编译Haskell程序: is it possible without downloading something such as Cygwin?

转载 作者:行者123 更新时间:2023-12-02 16:33:17 24 4
gpt4 key购买 nike

我正在阅读“为大善而学 Haskell”,并且已经读到了有关 I/O 操作的章节。我使用的是 Windows,并且已下载 GHCi 和 WinGHCi。

我正在尝试编译一个简单的程序,并在 emacs 上将文件保存为 helloworld.hs,其中包含 main = putStrLn "hello, world"

书上说

Open your terminal, navigate to the directory where helloworld.hs is located, and enter the following:

$ ghc --make helloworld

但是,如果我在 GHCi 和 WinGHCi 上输入 $ ghc --make helloworld ,我会收到如下错误,可能是因为我需要输入 $ ghc --make helloworld 其他地方:

<interactive>:7:1: error:
parse error on input ‘$’
Perhaps you intended to use TemplateHaskell

事实上,在该书的网络版(此处: http://learnyouahaskell.com/input-and-output )中,作者指出:

For the purposes of this chapter, I'm going to assume you're using a unix-y environment for learning Haskell. If you're in Windows, I'd suggest you download Cygwin, which is a Linux-like environment for Windows, A.K.A. just what you need.

问题1:我是否有必要下载Cygwin或其他类似的东西,以便能够通过输入$来编译程序ghc --make helloworld

我问这个,因为如果有其他编译程序的方法,知道它会非常有用,因为我使用的是大学计算机,未经许可无法下载像 Cygwin 这样的东西。 (即使获得许可,也可能无法实现,具体取决于 Cygwin 的要求)

问题2:鉴于只有我大学的技术人员去复活节,并且只有他们可以在这台计算机上下载东西,我该如何继续本章在 I/O 操作中?是否可以直接继续,但忽略涉及编译程序的部分?

最佳答案

在许多 Unix 和 Linux shell 中(至少在我最熟悉的 Bash 中),默认提示符是 $。这就是 shell 显示的内容。

在 Windows 上,当您打开命令提示符时,您通常会看到类似这样的内容:

C:\Users\mark>

(这是我的提示。)

虽然指令通常包含 $ 提示符,以表明该代码是您需要在命令提示符下输入的内容,但您不需要键入 $ 。只需输入 ghc --make helloworld 并按 Enter

此外,您不应该从 GHCi 内执行此操作,而是从命令行执行此操作。 ghc 是一个命令行可执行文件(.exe),就像例如git。不过,它必须位于您的路径中,否则,您每次想要运行可执行文件时都必须键入可执行文件的完整路径。

关于haskell - 在Windows中编译Haskell程序: is it possible without downloading something such as Cygwin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49554792/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com