简体   繁体   English

如何使用 windows 的 powershell 运行 Haskell 文件?

[英]How can I run a Haskell file using window's powershell?

I downloaded chocolatey and am able to load up ghci and get prelude on powershell .我下载了chocolatey并且能够加载ghci并在powershell上获得前奏。 I then cd into the directory where I have a haskell file I want to run, then I type ghci and then type:然后我 cd 进入我想要运行的 haskell 文件的目录,然后我输入ghci然后输入:

load haskellprogram.hs

but then I get an error about it not being in scope.但后来我收到一个错误,提示它不在范围内。 Is this not how you run a Haskell program?这不是你运行 Haskell 程序的方式吗?

The GHCi command to load a file is :load , not load .加载文件的 GHCi 命令是:load ,而不是load You should write:你应该写:

:load haskellprogram.hs

The command can also be abbreviated :l .该命令也可以缩写为:l You can find more information about the available commands in GHCi by entering :help .您可以通过输入:help找到有关 GHCi 中可用命令的更多信息。 Also note that the prompt shows the modules you have imported;另请注意,提示会显示您已导入的模块; Prelude is just the name of the standard library module that gets imported by default. Prelude只是默认导入的标准库模块的名称。 You can change the prompt with:您可以使用以下命令更改提示:

:set prompt "> "
:set prompt-cont "| "

(Where prompt-cont is the prompt for multi-line input, using the commands :{ and :} or the multi-line input mode enabled by :set +m .) (其中prompt-cont是多行输入的提示,使用命令:{:}:set +m启用的多行输入模式。)

When you entered load haskellprogram.hs , it was interpreted as a Haskell expression: (load haskellprogram) . hs当您输入load haskellprogram.hs ,它被解释为 Haskell 表达式: (load haskellprogram) . hs (load haskellprogram) . hs , which tries to use the (.) composition operator and three variables load , haskellprogram , and hs that are not defined. (load haskellprogram) . hs ,它尝试使用(.)组合运算符和三个haskellprogram变量loadhaskellprogramhs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM