现在的位置: 首页 > 综合 > 正文

经典的Hello World 2010年9月21日星期二

2014年03月26日 ⁄ 综合 ⁄ 共 329字 ⁄ 字号 评论关闭

Haskell的教程里面,输入输出被放到了比较靠后的地方,因此经典的
Hello World
也在此时才能写出

代码如下:

module Main where

main = 

putStrLn "Hello, World!"

 

更复杂一点的

module Main where

main = do

putStrLn "Please enter your name:"

name <- getLine

putStrLn ("Hello, " ++ name ++ "!")

 

把代码保存到hello.hs
文件,编译:
ghc hello.hs
,得到
main.exe(
此外还有
hello.hi

hello.o
文件,暂时不知道作用
)
,文件比较大,一个简单的
Hello World
也有
900K

抱歉!评论已关闭.