Diffstat (limited to 'src/protocol/visitor/sequence.rs')
| -rw-r--r-- | src/protocol/visitor/sequence.rs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/protocol/visitor/sequence.rs b/src/protocol/visitor/sequence.rs index 2f8735d..736a006 100644 --- a/src/protocol/visitor/sequence.rs +++ b/src/protocol/visitor/sequence.rs @@ -1,8 +1,9 @@ use crate::{ + any::{MaybeSized, TypeName}, + bijective_higher_ranked_type, effect::{Effect, Future}, higher_ranked_type, hkt::AnySend, - nameable, protocol::{walker::hint::HintMeta, Visitor}, Flow, }; @@ -13,13 +14,21 @@ pub trait Sequence<'ctx, E: Effect<'ctx>> { fn visit<'a>(&'a mut self, scope: DynSequenceScope<'a, 'ctx, E>) -> Future<'a, 'ctx, Flow, E>; } -pub type DynSequence<'a, 'ctx, E> = dyn Sequence<'ctx, E> + Send + 'a; - -nameable! { - pub struct Name['ctx, E] for<'a>; +bijective_higher_ranked_type! { + pub type DynSequence['ctx][E]: MaybeSized['ctx][] + for<'a> + (dyn Sequence<'ctx, E> + Send + 'a) + where { + E: Effect<'ctx> + } +} - impl [E] for DynSequence<'a, 'ctx, E> where { - E: Effect<'ctx>, +bijective_higher_ranked_type! { + pub type [][E]: TypeName[][] + for<'ctx> + (DynSequence<'ctx, E>) + where { + E: Effect<'ctx> } } @@ -44,7 +53,7 @@ pub struct SequenceHint { pub len: (usize, Option<usize>), } -impl<'a, 'ctx: 'a, E: Effect<'ctx>> HintMeta<'ctx> for DynSequence<'a, 'ctx, E> { +impl<'ctx, E: Effect<'ctx>> HintMeta<'ctx> for DynSequence<'ctx, E> { type Known = SequenceKnownHkt<'ctx>; type Hint = SequenceHint; @@ -54,7 +63,7 @@ pub fn visit_sequence<'a, 'ctx, E: Effect<'ctx>>( visitor: Visitor<'a, 'ctx>, scope: DynSequenceScope<'a, 'ctx, E>, ) -> Future<'a, 'ctx, Status, E> { - if let Some(object) = visitor.upcast_mut::<DynSequence<'_, 'ctx, E>>() { + if let Some(object) = visitor.upcast_mut::<DynSequence<'ctx, E>>() { // Allow the visitor to give a hint if it wants. E::map(object.visit(scope), |flow| match flow { Flow::Continue => { |