-- Equivalent definitions of sum (over lists of integers)
-- (1) Conditional expression
sum' :: [Integer] -> Integer
sum' xs = if xs == [] then 0 else head xs + sum' (tail xs)
-- (2) Guards
sum'' :: [Integer] -> Integer
sum'' xs | xs == [] = 0
| otherwise = head xs + sum'' (tail xs)
-- (3) Pattern matching
sum''' :: [Integer] -> Integer
sum''' [] = 0
sum''' (x:xs) = x + sum''' xs
main :: IO ()
main = print $ (sum' [1..100], sum'' [1..100], sum''' [1..100])