Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1.26 KB

01.md

File metadata and controls

39 lines (31 loc) · 1.26 KB

First steps

Today you will set up a basic development environment and write your first Haskell program.

Development environment

First you need to set up a development environment. The easiest way is to install the Haskell platform which contains much more than what we need now. You will find specific instructions for your operating system here. Today we are going to need only ghc the Glasgow Haskell Compiler.

First Haskell program

Create the Hello.hs file with you favourite text editor with the following content. Please type it in instead of just copy pasting.

module Main where
main = putStrLn "Good bye imperative world!"

The next step is to compile and run it. Assuming you are using some kind of Unix like operating system.

$ ghc ./Hello.hs
$ ./Hello

We defined the Main module in the Hello.hs file. Modules are used to control name spaces and to organize source code. The Main module is expected to have a function called main. The execution of a program starts with the main function.

Exercises

  • Modify Hello.hs to print out the following text: "My favourite text editor is vim!"
  • Delete the main function and compile Hello.hs. Try to understand the error message.