module StackMachine where import System.IO type Transition state input output = (state, input) -> (state, output) process :: Transition state input output -> state -> [input] -> [output] runprocess :: Transition state String String -> state -> IO () runprocess tr s = do hSetBuffering stdout LineBuffering -- requires: ``import System.IO'' interact (unlines . process tr s . lines) countEcho :: Transition Integer String String trAdd :: Transition Integer String String polish :: Transition [Integer] String String