- To be able to explain the notion of a function in the functional programming paradigm in a precise way
- To understand the central points in the history of functional programming
- To be able to install the Glasgow Haskell compiler and use it with a simple programming environment
- To be able to write simple definitions in Haskell
- To be able to edit, load and use simple Haskell scripts
- To understand and be able to apply simple aspects of Haskell syntax: Definitions, comments, the layout rule and where declarations in definitions
Run and debug fast
ghci filename.hs to start with a file loaded.
When in ghci, here are some useful commands:
:set editor <name> to set editor to name
:edit <name> to edit script name
:edit to edit current script
:type <expr> to show type of expression
:? for help
- Function and arguments begins with a lower-case letter. Capital letters are for types.
- List arguments usually have an
s suffix. E.g.
Haskell has library functions. Many functions are useful on lists. Imagine the lists have elements.
x represents a number.
- Select first element of list:
- Remove the first element from a list:
- Select the nth element of a list:
 !! x
- Select the first nth element of a list:
take x 
- Remove first n elements from a list:
drop x 
- Calculate length of list:
- Calculate sum of list of numbers:
- Calculate product of a list of numbers:
- Append two lists:
 ++ 
- Reverse a list:
Function application is denoted using space.
Multiplication is denoted using
f with parameters
f a b
Function calls have higher priority than any other operator.
f a + b means
(f a) + b.
A function can be a total function or a Partial function.
f x y
f (g x )
f x (g y)
f x * g y
The Layout Rule
In a sequence of definitions, each definition must begin in precisely the same column.
Meaning, it works on indentation. So you don’t need to explicitly define groupings of definitions.