main = putStrLn "hello, world"
1、定义函数main;
2、调用putStrLn;(与python中print一致)
3、用hello,world调用putStrLn。
如何编译程序?
1、打开你的终端并切换到包含 helloworld.hs 的目录;(powershell中通过cd切换目录,如下,ps为powershell自带,意义不明)
PS C:\Users\江仞树> cd C:\Haskell\project
PS C:\Haskell\project>
2、输入如下指令;其中第一排为指令(注意开头的$为趣学指南自带,powershell中不要输入$,意义不明),后续两排为指令正常运行后的显示内容
$ ghc --make helloworld[ 1 of 1 ] Compiling Main ( helloworld.hs, hellowowlrd.o )Linking helloworld ...
3、 运行程序;($如上)
$ ./helloworldhello , world