-- THE non-deterministic operation: coin :: Int coin = 0 coin = 1 -- the same without overlapping rules: coin2 :: Int coin2 = zeroOne x where x free zeroOne 0 = 0 zeroOne 1 = 1 aBool :: Bool aBool = False aBool = True -- Permuations: -- insert an element arbitrarily into a list insert :: a -> [a] -> [a] insert x ys = x : ys insert x (y:ys) = y : insert x ys perm :: [a] -> [a] perm [] = [] perm (x:xs) = insert x (perm xs) -- The identity on sorted lists, fails otherwise sorted :: Ord a => [a] -> [a] sorted [] = [] sorted [x] = [x] sorted (x:y:zs) | x <= y = x : sorted (y:zs) -- Sort a list sort :: Ord a => [a] -> [a] --sort xs = sorted (perm xs) sort = sorted . perm double :: Int -> Int double x = x + x double12 :: Int double12 = double (1 ? 2) -- Implementation of run-time choice: doubleRTC :: (() -> Int) -> Int doubleRTC x = x () + x () double12RTC :: Int double12RTC = doubleRTC (\() -> 1 ? 2)