module SK where import Delay import Control.Monad i_comb = App (App S_comb K_comb) K_comb k_run = App i_comb K_comb -- S (I K I) (K I) S => I big_i = App (App (App S_comb (App (App i_comb K_comb) i_comb)) (App K_comb i_comb)) S_comb test1 = run (evalSK k_run) -- K test2 = run (evalSK big_i) -- S K K natToInt O = 0 natToInt (S k) = (natToInt k) + 1 instance Show Nat where show = show.natToInt instance Show SK where show S_comb = "S" show K_comb = "K" show (App f a) = "(" ++ show f ++ " " ++ show a ++ ")" run :: Show a => Delay a -> IO () run v = putStrLn $ show (getDelayed v) getDelayed :: Delay a -> a getDelayed (Now a) = a getDelayed (Later x) = getDelayed x