(* Example demonstrating the core features of the library. *)
ITree ITreeFacts.
(* Custom effects *)
Variant inputE : Type -> Type :=
| Input : inputE nat.
(* Effectful programs *)
Definition echo : itree inputE nat
:= x <- trigger Input ;;
Ret x.
(* Effect handlers *)
Definition handler {E} (n : nat)
: inputE ~> itree E
:= fun _ e => match e with
| Input => Ret n
end.
(* Interpreters *)
Definition echoed (n : nat)
: itree void1 nat
:= interp (handler n) echo.

(* Equational reasoning *)
Theorem echoed_id : forall n, echoed n ≈ Ret n.