Diffstat (limited to 'src/protocol/visitor/sequence.rs')
| -rw-r--r-- | src/protocol/visitor/sequence.rs | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/protocol/visitor/sequence.rs b/src/protocol/visitor/sequence.rs index 23bc3ce..32deb9c 100644 --- a/src/protocol/visitor/sequence.rs +++ b/src/protocol/visitor/sequence.rs @@ -1,10 +1,5 @@ use crate::{ - any::{TypeName, WithContextLt}, - bijective_higher_ranked_type, - effect::{Effect, Future}, - hkt::AnySizedSend, - protocol::{walker::hint::HintMeta, Visitor}, - Flow, + any::{TypeName}, effect::{Effect, Future}, higher_ranked_type, hkt::Marker, protocol::{walker::hint::{HintKnown, HintMeta}, Visitor}, Flow }; use super::VisitResult; @@ -16,21 +11,21 @@ pub trait Sequence<'ctx, E: Effect> { ) -> Future<'a, VisitResult<DynSequenceScope<'a, 'ctx, E>>, E>; } -bijective_higher_ranked_type! { - pub type DynSequence['ctx][E]: WithContextLt['ctx][] - for<'a> - (dyn Sequence<'ctx, E> + Send + 'a) - where { - E: Effect - } -} +pub struct SequenceProto<E: Effect>(Marker<E>); + +higher_ranked_type! { + impl TypeName { + impl['a, 'ctx, E] type T['a, 'ctx] for SequenceProto<E> = + dyn Sequence<'ctx, E> + Send + 'a + where { + E: Effect + }; -bijective_higher_ranked_type! { - pub type [][E]: TypeName[][] - for<'ctx> - (DynSequence<'ctx, E>) - where { - E: Effect + impl['a, 'ctx, E] type HigherRanked['a, 'ctx] for dyn Sequence<'ctx, E> + Send + 'a = + SequenceProto<E> + where { + E: Effect + }; } } @@ -42,8 +37,14 @@ pub trait SequenceScope<'ctx, E: Effect> { pub type DynSequenceScope<'a, 'ctx, E> = &'a mut (dyn SequenceScope<'ctx, E> + Send + 'a); -bijective_higher_ranked_type! { - pub type SequenceKnownHkt[][]: AnySizedSend[][] for<'lt> (SequenceKnown) +higher_ranked_type! { + impl HintKnown { + impl['a] type T['a] for SequenceKnown = + SequenceKnown; + + impl['a] type HigherRanked['a] for SequenceKnown = + SequenceKnown; + } } #[derive(Default)] @@ -55,8 +56,8 @@ pub struct SequenceHint { pub len: (usize, Option<usize>), } -impl<'ctx, E: Effect> HintMeta<'ctx> for DynSequence<'ctx, E> { - type Known = SequenceKnownHkt; +impl<'ctx, E: Effect> HintMeta<'ctx> for SequenceProto<E> { + type Known = SequenceKnown; type Hint = SequenceHint; } @@ -65,7 +66,7 @@ pub fn visit_sequence<'a, 'ctx, E: Effect>( visitor: Visitor<'a, 'ctx>, scope: DynSequenceScope<'a, 'ctx, E>, ) -> Future<'a, VisitResult<DynSequenceScope<'a, 'ctx, E>>, E> { - if let Some(object) = visitor.upcast_mut::<DynSequence<'ctx, E>>() { + if let Some(object) = visitor.upcast_mut::<SequenceProto<E>>() { // Allow the visitor to give a hint if it wants. object.visit(scope) } else { |