coin :: Int
coin = 0
coin = 1
coin' :: Int
coin' = zeroOne _
where
zeroOne 0 = 0
zeroOne 1 = 1
-- Non-deterministic list insertion:
insert :: a -> [a] -> [a]
insert x ys = x : ys
insert x (y:ys) = y : insert x ys
-- Permutation of a list:
perm :: [a] -> [a]
perm [] = []
perm (x:xs) = insert x (perm xs)
-- Identity on sorted lists:
sorted :: Ord a => [a] -> [a]
sorted [] = []
sorted [x] = [x]
sorted (x:y:zs) | x<=y = x : sorted (y:zs)
-- Sorting a list, e.g., a specification of sorting a list:
sort :: Ord a => [a] -> [a]
sort xs = sorted (perm xs)