Skip to content
UoL CS Notes

Lecture 3-1

COMP105 Lectures

Functions and Libraries

When using Haskell the default library is Prelude.

Haskell uses special syntax for function calls. min from the Prelude library will work as min 1 2. This is as functions are called as:

[function name][space][arg1][space][arg2]...

Additionally in Haskell functions bind tighter than mathematical operators:

Prelude> min 28 100/4
7.0
Prelude> min 28 (100/4)
25.0

Two Argument Function Syntax

Functions will two arguments can be infixed by surrounding with back-ticks:

Prelude> mod 10 4
2
Prelude> 10 `mod` 4
2

For infix functions like + you can surround them with brackets and use them like a prefix function:

Prelude> 1 + 1
2
Prelude> (+) 1 1
2

Additional functions are available in the slides.