These statements use a logical expression called a condition to chose between two results of the same Type. If the condition is True then the first result is chosen, and if it is False then the second is chosen.

The syntax is if condition then res1 else res2.

Examples

The function abs that returns the absolute value of an integer can be defined as

abs :: Int -> Int
abs n = if n >= 0 then n else -n