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