Hello world

In accordance with tradition, we begin with a tiny example program that prints a friendly greeting.

This is the complete source for this program.

main = putStrLn "hello world"

Put the code into a file named hello-world.hs.

Use the runhaskell command to run the program.

$ runhaskell hello-world.hs
hello world

A Haskell program can also be compiled. For this we use GHC (the Glasgow Haskell Compiler).

$ ghc hello-world.hs
$ ls
hello-world hello-world.hi hello-world.hs hello-world.o

Then we can execute the hello-world binary.

$ ./hello-world
hello world