fact: Definition try_catch {Err R : Type } {E : Type -> Type} (ttry : itree (exceptE Err +' E) R) (kcatch : Err -> itree (exceptE Err +' E) R) : itree (exceptE Err +' E) R := let catch_body (t : itree (exceptE Err +' E) R) : itree (exceptE Err +' E) ((itree (exceptE Err +' E) R) + R ) := match observe t with | RetF r => Ret (inr r) | TauF t' => Ret (inl t') | VisF e k => match e with | inl1 (Throw exc) => Functor.fmap inr (kcatch exc) | inr1 e' => Functor.fmap (fun x => inl (k x) ) (trigger e) end end in ITree.iter catch_body ttry.
imports: ITree(ITree)