@@ -21,7 +21,8 @@ From Coq Require Import
2121From ExtLib Require Import
2222 Monad
2323 Traversable
24- Data.List.
24+ Data.List
25+ Data.Monads.StateMonad.
2526
2627From ITree Require Import
2728 Simple.
@@ -30,6 +31,8 @@ Import ListNotations.
3031Import ITreeNotations.
3132Import MonadNotation.
3233Open Scope monad_scope.
34+
35+ Existing Instance Monad_stateT.
3336(* end hide *)
3437
3538(** * Events *)
@@ -75,25 +78,25 @@ Definition write_one : itree ioE unit :=
7578 - [void1] is the empty event (so the resulting ITree can trigger
7679 no event). *)
7780
78- Compute Monads. stateT (list nat) (itree void1) unit.
81+ Compute stateT (list nat) (itree void1) unit.
7982Print void1.
8083
8184Definition handle_io
82- : forall R, ioE R -> Monads. stateT (list nat) (itree void1) R
83- := fun R e log =>
84- match e with
85- | Input => ret (log, [0])
86- | Output o => ret (log ++ o, tt )
87- end .
85+ : forall R, ioE R -> stateT (list nat) (itree void1) R
86+ := fun R e => mkStateT ( fun log =>
87+ match e in ioE R return itree void1 (R * list nat) with
88+ | Input => ret ([0], log )
89+ | Output o => ret (tt, log ++ o)
90+ end ) .
8891
8992(** [interp] lifts any handler into an _interpreter_, of type
9093 [forall R, itree ioE R -> M R]. *)
9194Definition interp_io
92- : forall R, itree ioE R -> itree void1 (list nat * R )
93- := fun R t => Monads.run_stateT (interp handle_io t) [].
95+ : forall R, itree ioE R -> itree void1 (R * list nat )
96+ := fun R t => runStateT (interp handle_io t) [].
9497
9598(** We can now interpret [write_one]. *)
96- Definition interpreted_write_one : itree void1 (list nat * unit )
99+ Definition interpreted_write_one : itree void1 (unit * list nat )
97100 := interp_io _ write_one.
98101
99102(** Intuitively, [interp_io] replaces every [ITree.trigger] in the
0 commit comments