Diffstat (limited to 'src/protocol/visitor.rs')
| -rw-r--r-- | src/protocol/visitor.rs | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/protocol/visitor.rs b/src/protocol/visitor.rs index a00f666..feb9c02 100644 --- a/src/protocol/visitor.rs +++ b/src/protocol/visitor.rs @@ -1,3 +1,5 @@ +use core::ops::ControlFlow; + use crate::{Flow, Status}; mod recoverable; @@ -7,10 +9,7 @@ mod tag; mod value; use effectful::{ - bound::HasSendAndSync, - effective::{Effective, SplitUpdateEffective}, - environment::{DynBind, Environment, InEnvironment, NativeForm}, - SendSync, + bound::HasSendAndSync, effective::{Canonical, Effective, UpdatePartial}, environment::{Environment, InEnvironment}, DynBind, SendSync }; pub use recoverable::*; pub use request_hint::*; @@ -91,7 +90,7 @@ impl<S> VisitResult<S> { } } -pub type IfSkippedEffective<'ctx, 'lt, 'wrap, Cap, Update, Eff> = SplitUpdateEffective< +pub type IfSkippedEffective<'ctx, 'lt, 'wrap, Cap, Update, Eff> = UpdatePartial< 'wrap, 'lt, (), @@ -102,12 +101,14 @@ pub type IfSkippedEffective<'ctx, 'lt, 'wrap, Cap, Update, Eff> = SplitUpdateEff Cap, &'a mut Update, ) - -> NativeForm<'a, VisitResult<()>, <Eff as InEnvironment>::Env, &'ctx ()>, + -> Canonical<'a, VisitResult<()>, <Eff as InEnvironment>::Env, &'ctx ()>, >, ), + (), Update, + (), VisitResult<()>, - VisitResult<()>, + (Update, VisitResult<()>), Eff, >; @@ -115,7 +116,7 @@ type IfSkippedF<'ctx, Cap, Update, Eff> = for<'a> fn( Cap, &'a mut Update, - ) -> NativeForm<'a, VisitResult<()>, <Eff as InEnvironment>::Env, &'ctx ()>; + ) -> Canonical<'a, VisitResult<()>, <Eff as InEnvironment>::Env, &'ctx ()>; pub trait EffectiveVisitExt<'lt>: Effective<'lt> { fn if_skipped<'ctx, 'wrap, Cap, Update>( @@ -130,14 +131,16 @@ pub trait EffectiveVisitExt<'lt>: Effective<'lt> { 'ctx: 'lt, 'lt: 'wrap, { - self.split_update( + self.update_partial( (), - |_, x| x, - (cap, HasSendAndSync(f)), - |(cap, HasSendAndSync(f)), update, value| match value { - VisitResult::Skipped(()) => f(cap, update), - _ => Self::Env::value(value).cast(), + |_, (update, result)| match result { + VisitResult::Skipped(()) => (update, ControlFlow::Continue(())), + VisitResult::Control(_) => (update, ControlFlow::Break(result)), }, + (cap, HasSendAndSync(f)), + |(cap, HasSendAndSync(f)), update, ()| f(cap, update), + (), + |_, update, out| (update, out) ) } @@ -153,14 +156,16 @@ pub trait EffectiveVisitExt<'lt>: Effective<'lt> { 'ctx: 'lt, 'lt: 'wrap, { - self.split_update( + self.update_partial( (), - |_, x| x, - (cap, HasSendAndSync(f)), - |(cap, HasSendAndSync(f)), update, value| match value { - VisitResult::Skipped(()) | VisitResult::Control(Flow::Continue) => f(cap, update), - _ => Self::Env::value(value).cast(), + |_, (update, result)| match result { + VisitResult::Skipped(()) | VisitResult::Control(Flow::Continue) => (update, ControlFlow::Continue(())), + VisitResult::Control(_) => (update, ControlFlow::Break(result)), }, + (cap, HasSendAndSync(f)), + |(cap, HasSendAndSync(f)), update, ()| f(cap, update), + (), + |_, update, out| (update, out) ) } } |