module IO where import ST type MyState = ((Integer, Integer), String, String) type MyIO a = ST MyState a setXIO :: x -> ST ((x, y), i, o) () setXIO v = \ ((x, y), i, o) -> ((), ((v, y), i, o)) setYIO :: y -> ST ((x, y), i, o) () setYIO v = \ ((x, y), i, o) -> ((), ((x, v), i, o)) getXIO :: () -> ST ((x, y), i, o) x getXIO () = \ ((x, y), i, o) -> (x, ((x, y), i, o)) getYIO :: () -> ST ((x, y), i, o) y getYIO () = \ ((x, y), i, o) -> (y, ((x, y), i, o)) readIO :: () -> MyIO Char readIO () = \ (s, c:cs, o) -> (c, (s, cs, o)) writeIO :: Show s => s -> MyIO () writeIO v = \ (s, i, o) -> ((), (s, i, o ++ show v))