Diffstat (limited to 'src/protocol/visitor/recoverable.rs')
| -rw-r--r-- | src/protocol/visitor/recoverable.rs | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/protocol/visitor/recoverable.rs b/src/protocol/visitor/recoverable.rs index b43344f..fe8d82e 100644 --- a/src/protocol/visitor/recoverable.rs +++ b/src/protocol/visitor/recoverable.rs @@ -1,6 +1,7 @@ +use effectful::{environment::{DynBind, EnvConfig, Environment, NativeForm}, is_send_sync}; + use crate::{ any::TypeName, - effect::{Effect, ErasedEffective, ReadyExt as _}, hkt::Marker, protocol::{ walker::hint::{HasProtocol, HintMeta, Meta}, @@ -11,51 +12,53 @@ use crate::{ use super::VisitResult; -pub trait Recoverable<'ctx, E: Effect> { +pub trait Recoverable<'ctx, E: Environment>: DynBind<E> { fn visit<'a>( &'a mut self, scope: DynRecoverableScope<'a, 'ctx, E>, - ) -> ErasedEffective<'a, VisitResult, E>; + ) -> NativeForm<'a, VisitResult, E>; } -pub struct RecoverableProto<E: Effect>(Marker<E>); +pub struct RecoverableProto<E: Environment>(Marker<E>); -impl<'a, 'ctx, E> TypeName::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> for RecoverableProto<E> +impl<'a, 'ctx, E> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for RecoverableProto<E> where - E: Effect, + E: Environment, { - type T = dyn Recoverable<'ctx, E> + Send + Sync + 'a; + type T = dyn Recoverable<'ctx, E> + 'a; } -impl<'a, 'ctx, E> TypeName::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> - for dyn Recoverable<'ctx, E> + Send + Sync + 'a +impl<'a, 'ctx, E> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> + for dyn Recoverable<'ctx, E> + 'a where - E: Effect, + E: Environment, { type Higher = RecoverableProto<E>; } -pub trait RecoverableScope<'ctx, E: Effect> { +pub trait RecoverableScope<'ctx, E: Environment>: DynBind<E> { fn new_walk<'this: 'effect, 'visitor: 'effect, 'effect>( &'this mut self, - visitor: DynVisitor<'visitor, 'ctx>, - ) -> ErasedEffective<'effect, Status, E>; + visitor: DynVisitor<'visitor, 'ctx, E>, + ) -> NativeForm<'effect, Status, E>; } pub type DynRecoverableScope<'a, 'ctx, E> = - &'a mut (dyn RecoverableScope<'ctx, E> + Send + Sync + 'a); + &'a mut (dyn RecoverableScope<'ctx, E> + 'a); pub struct RecoverableKnown; -impl<'a, 'ctx> Meta::MemberTypeForLt<'a, 'ctx, &'a &'ctx ()> for RecoverableKnown { +is_send_sync!(RecoverableKnown); + +impl<'a, 'ctx, E: EnvConfig> Meta::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for RecoverableKnown { type T = RecoverableKnown; } -impl<'a, 'ctx> Meta::LowerTypeWithBound<'a, 'ctx, &'a &'ctx ()> for RecoverableKnown { +impl<'a, 'ctx, E: EnvConfig> Meta::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()> for RecoverableKnown { type Higher = RecoverableKnown; } -impl<E: Effect> HintMeta for RecoverableProto<E> { +impl<E: Environment> HintMeta for RecoverableProto<E> { type Known = RecoverableKnown; type Hint = (); @@ -63,17 +66,17 @@ impl<E: Effect> HintMeta for RecoverableProto<E> { type Effect = E; } -pub fn visit_recoverable<'a, 'ctx, E: Effect>( - visitor: DynVisitor<'a, 'ctx>, +pub fn visit_recoverable<'a, 'ctx, E: Environment>( + visitor: DynVisitor<'a, 'ctx, E>, scope: DynRecoverableScope<'a, 'ctx, E>, -) -> ErasedEffective<'a, VisitResult, E> { +) -> NativeForm<'a, VisitResult, E> { if let Some(object) = visitor.0.upcast_mut::<RecoverableProto<E>>() { // Allow the visitor to give a hint if it wants. object.visit(scope) } else { // If the visitor doesn't support request hint then we continue. - VisitResult::Skipped(()).ready() + E::value(VisitResult::Skipped(())).cast() } } -impl<'ctx, T, E: Effect> HasProtocol<RecoverableProto<E>> for T where T: Recoverable<'ctx, E> {} +impl<'ctx, T, E: Environment> HasProtocol<RecoverableProto<E>> for T where T: Recoverable<'ctx, E> {} |