July 2023
Intermediate to advanced
670 pages
17h 13m
English
Now that you have some experience evaluating expressions, it’s time to write your first complete Haskell program. We’ll start with an obligatory “Hello World” program by creating a new empty file named Main.hs in your Chapter1 directory.
Open Main.hs and copy this example:
| | module Main where |
| | main = print "Hello, World!" |
You’ll learn what each of these lines is doing as you work your way through the chapter, but for now let’s build the application and run your program.
From your command line you can compile your program by typing ghc Main. After the program is built you’ll have a new executable, Main, that you can run to see your message:
| | user@host$ ghc Main |
| | [1 of 1] Compiling Main ( Main.hs, ... |