2018-08-16 19:42:38 +03:00
|
|
|
effect State s where
|
|
|
|
get : {State s} s
|
|
|
|
set : s -> {State s} ()
|
|
|
|
|
|
|
|
effect Console where
|
|
|
|
read : {Console} (Optional Text)
|
|
|
|
write : Text -> {Console} ()
|
|
|
|
|
|
|
|
fst x = case x of Pair.Pair a _ -> a
|
|
|
|
|
|
|
|
snd x = case x of Pair.Pair _ (Pair.Pair b _) -> b
|
|
|
|
|
|
|
|
namespace Console where
|
|
|
|
|
|
|
|
simulate : Effect Console a -> {State ([Text], [Text])} a
|
|
|
|
simulate c = case c of
|
|
|
|
{Console.read -> k} ->
|
|
|
|
io = State.get
|
|
|
|
ins = fst io
|
|
|
|
outs = snd io
|
|
|
|
State.set (drop 1 ins, outs)
|
2018-08-17 19:42:03 +03:00
|
|
|
k (at 0 ins) -- this is missing recursive call to handle
|
2018-08-16 19:42:38 +03:00
|
|
|
{Console.write t -> k} ->
|
|
|
|
io = State.get
|
|
|
|
ins = fst io
|
|
|
|
outs = snd io
|
2018-08-17 19:42:03 +03:00
|
|
|
k (State.set (ins, cons t outs)) -- this is missing recursive call
|
2018-08-16 19:42:38 +03:00
|
|
|
|
|
|
|
()
|
|
|
|
|