Diffstat (limited to 'src/protocol/visitor/recoverable.rs')
| -rw-r--r-- | src/protocol/visitor/recoverable.rs | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/protocol/visitor/recoverable.rs b/src/protocol/visitor/recoverable.rs index e23c69e..af3e494 100644 --- a/src/protocol/visitor/recoverable.rs +++ b/src/protocol/visitor/recoverable.rs @@ -1,10 +1,5 @@ use crate::{ - any::{TypeName, WithContextLt}, - bijective_higher_ranked_type, - effect::{Effect, Future}, - hkt::AnySizedSend, - protocol::{walker::hint::HintMeta, Visitor}, - Status, + any::{TypeName}, effect::{Effect, Future}, higher_ranked_type, hkt::Marker, protocol::{walker::hint::{HintKnown, HintMeta}, Visitor}, Status }; use super::VisitResult; @@ -16,21 +11,21 @@ pub trait Recoverable<'ctx, E: Effect> { ) -> Future<'a, VisitResult<DynRecoverableScope<'a, 'ctx, E>>, E>; } -bijective_higher_ranked_type! { - pub type DynRecoverable['ctx][E]: WithContextLt['ctx][] - for<'a> - (dyn Recoverable<'ctx, E> + Send + 'a) - where { - E: Effect - } -} +pub struct RecoverableProto<E: Effect>(Marker<E>); + +higher_ranked_type! { + impl TypeName { + impl['a, 'ctx, E] type T['a, 'ctx] for RecoverableProto<E> = + dyn Recoverable<'ctx, E> + Send + 'a + where { + E: Effect + }; -bijective_higher_ranked_type! { - pub type [][E]: TypeName[][] - for<'ctx> - (DynRecoverable<'ctx, E>) - where { - E: Effect + impl['a, 'ctx, E] type HigherRanked['a, 'ctx] for dyn Recoverable<'ctx, E> + Send + 'a = + RecoverableProto<E> + where { + E: Effect + }; } } @@ -40,12 +35,20 @@ pub trait RecoverableScope<'ctx, E: Effect> { pub type DynRecoverableScope<'a, 'ctx, E> = &'a mut (dyn RecoverableScope<'ctx, E> + Send + 'a); -bijective_higher_ranked_type! { - pub type RecoverableKnownHkt[][]: AnySizedSend[][] for<'lt> (()) +pub struct RecoverableKnown; + +higher_ranked_type! { + impl HintKnown { + impl['a] type T['a] for RecoverableKnown = + RecoverableKnown; + + impl['a] type HigherRanked['a] for RecoverableKnown = + RecoverableKnown; + } } -impl<'ctx, E: Effect> HintMeta<'ctx> for DynRecoverable<'ctx, E> { - type Known = RecoverableKnownHkt; +impl<'ctx, E: Effect> HintMeta<'ctx> for RecoverableProto<E> { + type Known = RecoverableKnown; type Hint = (); } @@ -54,7 +57,7 @@ pub fn visit_recoverable<'a, 'ctx, E: Effect>( visitor: Visitor<'a, 'ctx>, scope: DynRecoverableScope<'a, 'ctx, E>, ) -> Future<'a, VisitResult<DynRecoverableScope<'a, 'ctx, E>>, E> { - if let Some(object) = visitor.upcast_mut::<DynRecoverable<'ctx, E>>() { + if let Some(object) = visitor.upcast_mut::<RecoverableProto<E>>() { // Allow the visitor to give a hint if it wants. object.visit(scope) } else { |