-- Peano representation of natural numbers: data Nat = Z | S Nat deriving Show -- Addition on natural numbers: add :: Nat -> Nat -> Nat add Z n = n add (S m) n = S (add m n) -- A partial function: f :: Nat -> Nat -> Nat f (S m) n = Z -- Not normalizing: > add (add x Z) (add Z Z) -- Not normalizing: > f Z (add Z Z) g :: Bool -> Bool -> Int g False False = 0 g _ True = 1 loop :: Bool loop = loop -- Haskell pattern matching does not compute the normal form of -- -- > g loop True -- -- (in contrast to strategy "phi")