coin :: Int
coin = 0
coin = 1
coin' :: Int
coin' = zeroOne x
where
x free
zeroOne False = 0
zeroOne True = 1
-- Non-deterministic insertion of an element into a list.
insert :: a -> [a] -> [a]
insert x ys = x : ys
insert x (y:ys) = y : insert x ys
-- Some 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:ys) | x <= y = x : sorted (y:ys)
-- Sorting a list: specification of list sorting!
sort :: Ord a => [a] -> [a]
sort xs = sorted (perm xs)
-- Standard semantics: call-time choice
double :: Int -> Int
double x = x + x
d12 :: Int
d12 = double (1 ? 2) -- Results: 2 or 4
doubleRTC :: (() -> Int) -> Int
doubleRTC xr = xr () + xr ()
d12RTC :: Int
d12RTC = doubleRTC (\() -> 1 ? 2)