ITree.Events.Reader

Reader

Immutable environment.


Section Reader.

Variable (Env : Type).

Variant readerE : Type Type :=
| Ask : readerE Env.

Definition ask {E} `{readerE -< E} : itree E Env :=
  trigger Ask.

Definition eval_reader {E} : Env Handler readerE E :=
  fun r _ e
    match e with
    | AskRet r
    end.

Definition run_reader {E} : Env itree (readerE +' E) ~> itree E :=
  fun rinterp (case_ (eval_reader r) (id_ _)).

End Reader.

Arguments ask {Env E _}.
Arguments run_reader {Env E} _ _ _.