Diffstat (limited to 'src/protocol/visitor/recoverable.rs')
-rw-r--r--src/protocol/visitor/recoverable.rs75
1 files changed, 30 insertions, 45 deletions
diff --git a/src/protocol/visitor/recoverable.rs b/src/protocol/visitor/recoverable.rs
index 3939ab8..7ad36bf 100644
--- a/src/protocol/visitor/recoverable.rs
+++ b/src/protocol/visitor/recoverable.rs
@@ -1,16 +1,14 @@
use effectful::{
effective::Effective,
- environment::{DynBind, EnvConfig, Environment, NativeForm},
+ environment::{DynBind, EnvConfig, Environment, InEnvironment, NativeForm},
+ higher_ranked::Rank1,
SendSync,
};
use crate::{
- any::TypeName,
+ any::type_name,
hkt::Marker,
- protocol::{
- walker::hint::{HasProtocol, HintMeta, Meta},
- DynVisitor,
- },
+ protocol::{walker::hint::HintMeta, DynVisitor},
Status,
};
@@ -23,23 +21,29 @@ pub trait Recoverable<'ctx, E: Environment>: DynBind<E> {
) -> NativeForm<'a, VisitResult, E>;
}
-#[derive(SendSync)]
-pub struct RecoverableProto<E: Environment>(Marker<E>);
+const _: () = {
+ pub struct RecoverableProto<E>(Marker<E>);
-impl<'a, 'ctx, E> TypeName::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for RecoverableProto<E>
-where
- E: Environment,
-{
- type T = dyn Recoverable<'ctx, E> + 'a;
-}
+ impl<'a, 'ctx, E: 'static> type_name::Lower<'a, 'ctx, &'a &'ctx ()> for RecoverableProto<E> {
+ type Lowered = dyn Recoverable<'ctx, E> + 'a;
+ }
-impl<'a, 'ctx, E> TypeName::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()>
- for dyn Recoverable<'ctx, E> + 'a
-where
- E: Environment,
-{
- type Higher = RecoverableProto<E>;
-}
+ impl<'a, 'ctx, E: 'static> type_name::Raise<'a, 'ctx, &'a &'ctx ()>
+ for dyn Recoverable<'ctx, E> + 'a
+ {
+ type Raised = RecoverableProto<E>;
+ }
+
+ impl<E: Environment> HintMeta for RecoverableProto<E> {
+ type Known = Rank1<()>;
+
+ type Hint = Rank1<()>;
+ }
+
+ impl<E: Environment> InEnvironment for RecoverableProto<E> {
+ type Env = E;
+ }
+};
pub trait RecoverableScope<'ctx, E: Environment>: DynBind<E> {
fn new_walk<'this: 'effect, 'visitor: 'effect, 'effect>(
@@ -50,32 +54,15 @@ pub trait RecoverableScope<'ctx, E: Environment>: DynBind<E> {
pub type DynRecoverableScope<'a, 'ctx, E> = &'a mut (dyn RecoverableScope<'ctx, E> + 'a);
-#[derive(SendSync)]
-pub struct RecoverableKnown;
-
-impl<'a, 'ctx, E: EnvConfig> Meta::MemberTypeForLt<'a, 'ctx, E, &'a &'ctx ()> for RecoverableKnown {
- type T = RecoverableKnown;
-}
-
-impl<'a, 'ctx, E: EnvConfig> Meta::LowerTypeWithBound<'a, 'ctx, E, &'a &'ctx ()>
- for RecoverableKnown
-{
- type Higher = RecoverableKnown;
-}
-
-impl<E: Environment> HintMeta for RecoverableProto<E> {
- type Known = RecoverableKnown;
-
- type Hint = ();
-
- type Effect = E;
-}
-
pub fn visit_recoverable<'a, 'ctx, E: Environment>(
visitor: DynVisitor<'a, 'ctx, E>,
scope: DynRecoverableScope<'a, 'ctx, E>,
) -> NativeForm<'a, VisitResult, E> {
- if let Some(object) = visitor.0.upcast_mut::<RecoverableProto<E>>() {
+ if let Some(object) = visitor
+ .0
+ .cast_mut()
+ .upcast_mut::<dyn Recoverable<'ctx, E> + 'a>()
+ {
// Allow the visitor to give a hint if it wants.
object.visit(scope)
} else {
@@ -83,5 +70,3 @@ pub fn visit_recoverable<'a, 'ctx, E: Environment>(
E::value(VisitResult::Skipped(())).cast()
}
}
-
-impl<'ctx, T, E: Environment> HasProtocol<RecoverableProto<E>> for T where T: Recoverable<'ctx, E> {}