-rw-r--r--Cargo.lock72
-rw-r--r--src/any.rs28
-rw-r--r--src/build.rs16
-rw-r--r--src/build/builders/core.rs16
-rw-r--r--src/build/builders/core/bool.rs4
-rw-r--r--src/build/builders/core/enum.rs154
-rw-r--r--src/build/builders/core/struct.rs203
-rw-r--r--src/build/builders/core/value.rs75
-rw-r--r--src/macros/build.rs44
-rw-r--r--src/protocol.rs77
-rw-r--r--src/protocol/visitor.rs45
-rw-r--r--src/protocol/visitor/recoverable.rs21
-rw-r--r--src/protocol/visitor/request_hint.rs20
-rw-r--r--src/protocol/visitor/sequence.rs23
-rw-r--r--src/protocol/visitor/tag.rs39
-rw-r--r--src/protocol/visitor/value.rs13
-rw-r--r--src/protocol/walker/hint.rs42
-rw-r--r--src/transform.rs78
-rw-r--r--src/walk.rs33
-rw-r--r--src/walk/walkers/core/bool.rs8
-rw-r--r--src/walk/walkers/core/int.rs23
-rw-r--r--src/walk/walkers/core/key_value.rs12
-rw-r--r--src/walk/walkers/core/noop.rs10
-rw-r--r--src/walk/walkers/core/struct.rs92
-rw-r--r--src/walk/walkers/core/tag.rs20
-rw-r--r--src/walk/walkers/core/value.rs19
-rw-r--r--src/walk/walkers/serde/deserializer.rs92
-rw-r--r--tests/builder_enum.rs5
-rw-r--r--tests/builder_struct.rs16
-rw-r--r--tests/builder_value.rs12
-rw-r--r--tests/common/builder.rs19
-rw-r--r--tests/common/mod.rs4
-rw-r--r--tests/common/protocol/hint.rs26
-rw-r--r--tests/common/protocol/recoverable.rs28
-rw-r--r--tests/common/protocol/request_hint.rs10
-rw-r--r--tests/common/protocol/sequence.rs18
-rw-r--r--tests/common/protocol/tag.rs21
-rw-r--r--tests/common/protocol/value.rs32
-rw-r--r--tests/common/walker.rs11
-rw-r--r--tests/protocol_visitor_recoverable.rs11
-rw-r--r--tests/protocol_visitor_request_hint.rs23
-rw-r--r--tests/protocol_visitor_sequence.rs17
-rw-r--r--tests/protocol_visitor_tag.rs47
-rw-r--r--tests/protocol_visitor_value.rs49
-rw-r--r--tests/protocol_walker_hint.rs2
-rw-r--r--tests/walker_struct.rs41
46 files changed, 807 insertions, 864 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d67f352..807a57f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -93,19 +93,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
-name = "disjoint_impls"
-version = "0.7.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "00eea056440e98b1ccf1c88ad475410873bd306214e25f1dcad97922bd0bb514"
-dependencies = [
- "proc-macro-error",
- "proc-macro2",
- "quote",
- "rustc-hash",
- "syn 2.0.68",
-]
-
-[[package]]
name = "downcast"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -115,7 +102,6 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1"
name = "effectful"
version = "0.1.0"
dependencies = [
- "disjoint_impls",
"effectful-derive",
"mini-macro-magic",
]
@@ -126,7 +112,7 @@ version = "0.1.0"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -213,7 +199,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -381,7 +367,7 @@ dependencies = [
"cfg-if",
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -459,7 +445,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -507,30 +493,6 @@ dependencies = [
]
[[package]]
-name = "proc-macro-error"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
-dependencies = [
- "proc-macro-error-attr",
- "proc-macro2",
- "quote",
- "syn 1.0.109",
- "version_check",
-]
-
-[[package]]
-name = "proc-macro-error-attr"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
-dependencies = [
- "proc-macro2",
- "quote",
- "version_check",
-]
-
-[[package]]
name = "proc-macro2"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -635,12 +597,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
-name = "rustc-hash"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
-
-[[package]]
name = "rustix"
version = "0.38.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -694,7 +650,7 @@ checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -744,16 +700,6 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.109"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
-dependencies = [
- "proc-macro2",
- "unicode-ident",
-]
-
-[[package]]
-name = "syn"
version = "2.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9"
@@ -809,7 +755,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.68",
+ "syn",
]
[[package]]
@@ -840,12 +786,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
-name = "version_check"
-version = "0.9.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
-
-[[package]]
name = "wait-timeout"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/src/any.rs b/src/any.rs
index 0594e68..86c566a 100644
--- a/src/any.rs
+++ b/src/any.rs
@@ -16,31 +16,31 @@ pub use ref_any_unsized::*;
pub use static_wrapper::*;
pub use type_name_id::*;
-pub trait AnyTrait<'ctx> {
- fn upcast_by_id<'a, 'lt: 'a>(
+pub trait AnyTrait<'lt, 'ctx: 'lt>: 'lt {
+ fn upcast_by_id<'a>(
&'a self,
id: WithLtTypeId<'lt, 'ctx>,
) -> Option<RefAnyUnsized<'a, 'lt, 'ctx>>
where
- 'ctx: 'lt,
+ 'lt: 'a
{
let _id = id;
None
}
- fn upcast_by_id_mut<'a, 'lt: 'a>(
+ fn upcast_by_id_mut<'a>(
&'a mut self,
id: WithLtTypeId<'lt, 'ctx>,
) -> Option<MutAnyUnsized<'a, 'lt, 'ctx>>
where
- 'ctx: 'lt,
+ 'lt: 'a
{
let _id = id;
None
}
}
-impl<'lt, 'ctx: 'lt> dyn AnyTrait<'ctx> + 'lt {
+impl<'lt, 'ctx: 'lt> dyn AnyTrait<'lt, 'ctx> + 'lt {
#[track_caller]
pub fn upcast<'a, T: ?Sized + type_name::WithLt<'lt, 'ctx>>(&'a self) -> Option<&'a T> {
self.upcast_by_id(WithLtTypeId::of::<T>())
@@ -106,18 +106,16 @@ macro_rules! trait_by_id {
$this:ident,
$id:ident,
{
- type Impls<$lt:lifetime, $ctx:lifetime> = ($($trait:ty),* $(,)?);
-
- $($body:tt)*
+ type Impls = ($($trait:ty),* $(,)?);
}
} => {{
match $id {
$(
$id if $id == $crate::any::WithLtTypeId::of::<$trait>() => {
- Some($crate::any::RefAnyUnsized::new($this as &$trait))
+ return Some($crate::any::RefAnyUnsized::new($this as &$trait))
}
)*
- _ => { $($body)* }
+ _ => {}
}
}};
{
@@ -125,9 +123,7 @@ macro_rules! trait_by_id {
$this:ident,
$id:ident,
{
- type Impls<$lt:lifetime, $ctx:lifetime> = ($($trait:ty),* $(,)?);
-
- $($body:tt)*
+ type Impls = ($($trait:ty),* $(,)?);
}
} => {{
match $id {
@@ -136,10 +132,10 @@ macro_rules! trait_by_id {
eprintln!("a: {:?}\nb: {:?}", &$id, $crate::any::WithLtTypeId::of::<$trait>());
$id == $crate::any::WithLtTypeId::of::<$trait>()
}=> {
- Some($crate::any::MutAnyUnsized::new($this as &mut $trait))
+ return Some($crate::any::MutAnyUnsized::new($this as &mut $trait))
}
)*
- _ => { $($body)* }
+ _ => {}
}
}};
}
diff --git a/src/build.rs b/src/build.rs
index 16e1f95..bb210f8 100644
--- a/src/build.rs
+++ b/src/build.rs
@@ -1,7 +1,7 @@
use core::fmt::{Debug, Display};
pub mod builders;
-use effectful::environment::{DynBind, EnvConfig, Environment, NativeForm};
+use effectful::{bound::SsBound, effective::Canonical, environment::Environment, DynBind};
use crate::protocol::AsVisitor;
@@ -13,14 +13,14 @@ use crate::protocol::AsVisitor;
///
/// There can be one canonical builder per mode. The mode is specified by the `M` generic and
/// can be any type. It is only used as a type level tag.
-pub trait Build<'ctx, M, E: Environment>: Sized {
+pub trait Build<'lt, 'ctx, M, E: Environment>: Sized {
/// The canonical builder for mode `M`.
///
/// This builder will build values of type `Self`.
- type Builder: Builder<'ctx, E, Value = Self>;
+ type Builder: Builder<'lt, 'ctx, E, Value = Self>;
}
-pub trait BuilderTypes<C: EnvConfig> {
+pub trait BuilderTypes<C: SsBound> {
type Seed: DynBind<C>;
/// Error that can happen during filling the builder with data.
@@ -47,10 +47,10 @@ pub trait BuilderTypes<C: EnvConfig> {
/// the builder with data from it's walk.
/// - Call [`Self::build()`] to finish building the value and get any errors
/// that happened during filling it with data.
-pub trait Builder<'ctx, E: Environment>:
- DynBind<E> + AsVisitor<'ctx, E> + BuilderTypes<E> + Sized
+pub trait Builder<'lt, 'ctx, E: Environment>:
+ DynBind<E> + AsVisitor<'lt, 'ctx, E> + BuilderTypes<E> + Sized
{
- fn from_seed<'a>(seed: Self::Seed) -> NativeForm<'a, Self, E>
+ fn from_seed<'a>(seed: Self::Seed) -> Canonical<'a, Self, E>
where
Self: 'a;
@@ -58,7 +58,7 @@ pub trait Builder<'ctx, E: Environment>:
///
/// If an error happened with the builder during the walk
/// it will be reported here.
- fn build<'a>(self) -> NativeForm<'a, Result<Self::Output, Self::Error>, E>
+ fn build<'a>(self) -> Canonical<'a, Result<Self::Output, Self::Error>, E>
where
Self: 'a;
}
diff --git a/src/build/builders/core.rs b/src/build/builders/core.rs
index a865c25..1231eae 100644
--- a/src/build/builders/core.rs
+++ b/src/build/builders/core.rs
@@ -1,6 +1,6 @@
use effectful::{
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Canonical, Effective},
+ environment::Environment,
SendSync,
};
@@ -17,7 +17,7 @@ pub mod value;
// pub mod variant;
pub mod r#enum;
-pub mod r#struct;
+// pub mod r#struct;
pub mod tag_name;
#[derive(Default, SendSync)]
@@ -30,14 +30,14 @@ impl NoopVisitor {
}
}
-impl<'ctx> AnyTrait<'ctx> for NoopVisitor {}
+impl<'lt, 'ctx: 'lt> AnyTrait<'lt, 'ctx> for NoopVisitor {}
impl NoopVisitor {
- pub fn walk_dyn<'ctx: 'e, 'walker: 'e, 'e, E: Environment>(
- walker: DynWalkerObjSafe<'walker, 'ctx, E>,
- ) -> NativeForm<'e, VisitResult, E> {
+ pub fn walk_dyn<'ctx: 'd, 'walker: 'e, 'd: 'walker, 'e, E: Environment>(
+ walker: DynWalkerObjSafe<'walker, 'd, 'ctx, E>,
+ ) -> Canonical<'e, VisitResult, E> {
E::value(NoopVisitor::new())
- .update(walker, |walker, noop| {
+ .update_map(walker, |walker, noop| {
walker
.walk(DynVisitor(noop))
.map((), |_, x| x.to_continue().into())
diff --git a/src/build/builders/core/bool.rs b/src/build/builders/core/bool.rs
index a6fbaf4..de1c288 100644
--- a/src/build/builders/core/bool.rs
+++ b/src/build/builders/core/bool.rs
@@ -4,9 +4,9 @@ use effectful::environment::Environment;
macro_rules! value_builder {
[$($ty:ty),*] => {
- $(impl<'ctx, M, E: Environment> crate::Build<'ctx, M, E> for $ty
+ $(impl<'lt, 'ctx, M, E: Environment> crate::Build<'lt, 'ctx, M, E> for $ty
where
- ValueBuilder<$ty, Cloneable, E>: Builder<'ctx, E, Value = Self>,
+ ValueBuilder<$ty, Cloneable, E>: Builder<'lt, 'ctx, E, Value = Self>,
{
type Builder = ValueBuilder<$ty, Cloneable, E>;
})*
diff --git a/src/build/builders/core/enum.rs b/src/build/builders/core/enum.rs
index 4ca0a83..dd5b0b8 100644
--- a/src/build/builders/core/enum.rs
+++ b/src/build/builders/core/enum.rs
@@ -1,9 +1,10 @@
use core::fmt::{Debug, Display};
use effectful::bound::Dynamic;
-use effectful::effective::Effective;
-use effectful::environment::{DynBind, Environment, NativeForm};
+use effectful::effective::{Effective, Canonical};
+use effectful::environment::{Environment};
use effectful::SendSync;
+use effectful::DynBind;
use crate::any::{type_name, OwnedStatic, TempBorrowedStatic};
use crate::protocol::visitor::{DynRecoverableScope, Recoverable};
@@ -20,17 +21,17 @@ use crate::{
};
#[derive(SendSync)]
-pub struct EnumBuilder<'ctx, Info, Mode, E: Environment>
+pub struct EnumBuilder<'lt, 'ctx, Info, Mode, E: Environment>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
{
- inner: Inner<'ctx, Info, Mode, E>,
+ inner: Inner<'lt, 'ctx, Info, Mode, E>,
}
#[derive(SendSync)]
-enum Inner<'ctx, Info, Mode, E: Environment>
+enum Inner<'lt, 'ctx, Info, Mode, E: Environment>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
{
Temp,
Seed(Info::Seed),
@@ -38,7 +39,7 @@ where
Value(Result<Dynamic<Info::T>, Info::Error>),
}
-pub trait EnumBuildInfo<'ctx, Mode, E: Environment> {
+pub trait EnumBuildInfo<'lt, 'ctx, Mode, E: Environment>: 'lt {
type Builders: DynBind<E>;
type Seed: DynBind<E>;
@@ -54,17 +55,17 @@ pub trait EnumBuildInfo<'ctx, Mode, E: Environment> {
fn new_builder<'a>(
seed: Self::Seed,
variant: Self::VariantMarker,
- ) -> NativeForm<'a, Self::Builders, E>;
+ ) -> Canonical<'a, Self::Builders, E>;
fn finish_builder<'a>(
builder: Self::Builders,
- ) -> NativeForm<'a, Result<Dynamic<Self::T>, Self::Error>, E>
+ ) -> Canonical<'a, Result<Dynamic<Self::T>, Self::Error>, E>
where
Dynamic<Self::T>: DynBind<E>;
fn from_value<'a>(value: type_name::Lowered<'a, 'ctx, Self::ValueT>) -> Self::T;
- fn as_visitor<'a>(builder: &'a mut Self::Builders) -> DynVisitor<'a, 'ctx, E>;
+ fn as_visitor<'a>(builder: &'a mut Self::Builders) -> DynVisitor<'a, 'lt, 'ctx, E>;
fn marker_from_name(name: &str) -> Option<Self::VariantMarker>;
@@ -73,14 +74,14 @@ pub trait EnumBuildInfo<'ctx, Mode, E: Environment> {
fn guess_variant<'a>(
seed: Self::Seed,
scope: DynRecoverableScope<'a, 'ctx, E>,
- ) -> NativeForm<'a, Result<Dynamic<Self::T>, Self::Error>, E>
+ ) -> Canonical<'a, Result<Dynamic<Self::T>, Self::Error>, E>
where
Dynamic<Self::T>: DynBind<E>;
}
-impl<'ctx, Info, Mode, E: Environment> BuilderTypes<E> for EnumBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E: Environment> BuilderTypes<E> for EnumBuilder<'lt, 'ctx, Info, Mode, E>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
{
type Seed = Info::Seed;
@@ -96,15 +97,15 @@ where
}
}
-impl<'ctx, Info, Mode, E: Environment> Builder<'ctx, E> for EnumBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'lt, E: Environment> Builder<'lt, 'ctx, E> for EnumBuilder<'lt, 'ctx, Info, Mode, E>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
for<'a> Dynamic<type_name::Lowered<'a, 'ctx, Info::ValueT>>: DynBind<E>,
for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>,
Dynamic<OwnedStatic<u32>>: DynBind<E>,
{
- fn from_seed<'a>(seed: Self::Seed) -> NativeForm<'a, Self, E>
+ fn from_seed<'a>(seed: Self::Seed) -> Canonical<'a, Self, E>
where
Self: 'a,
{
@@ -114,7 +115,7 @@ where
.cast()
}
- fn build<'a>(self) -> NativeForm<'a, Result<Self::Output, Self::Error>, E>
+ fn build<'a>(self) -> Canonical<'a, Result<Self::Output, Self::Error>, E>
where
Self: 'a,
{
@@ -130,26 +131,23 @@ where
}
}
-impl<'ctx, Info, Mode, E: Environment> AsVisitor<'ctx, E> for EnumBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'lt, E: Environment> AsVisitor<'lt, 'ctx, E> for EnumBuilder<'lt, 'ctx, Info, Mode, E>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
for<'a> Dynamic<type_name::Lowered<'a, 'ctx, Info::ValueT>>: DynBind<E>,
for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>,
Dynamic<OwnedStatic<u32>>: DynBind<E>,
{
- fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'ctx, E>
- where
- 'ctx: 'a,
- {
+ fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'lt, 'ctx, E> {
DynVisitor(self)
}
}
-impl<'ctx, Info, Mode, E: Environment> AnyTrait<'ctx> for EnumBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx: 'lt, Info, Mode: 'lt, E: Environment> AnyTrait<'lt, 'ctx> for EnumBuilder<'lt, 'ctx, Info, Mode, E>
where
E: Environment,
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
for<'a> Dynamic<type_name::Lowered<'a, 'ctx, Info::ValueT>>: DynBind<E>,
for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>,
@@ -189,15 +187,15 @@ where
// Dynamic<OwnedStatic<u32>>: DynBind<E>,
// }
-impl<'ctx, Info, Mode, E: Environment> Recoverable<'ctx, E> for EnumBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E: Environment> Recoverable<'ctx, E> for EnumBuilder<'lt, 'ctx, Info, Mode, E>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
{
fn visit<'a>(
&'a mut self,
scope: DynRecoverableScope<'a, 'ctx, E>,
- ) -> NativeForm<'a, VisitResult, E> {
+ ) -> Canonical<'a, VisitResult, E> {
match core::mem::replace(&mut self.inner, Inner::Temp) {
Inner::Seed(seed) => Info::guess_variant(seed, scope)
.map(self, |this, result| {
@@ -213,16 +211,16 @@ where
}
}
-impl<'ctx, Info, Mode, E: Environment> Value<'ctx, Info::ValueT, E>
- for EnumBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E: Environment> Value<'ctx, Info::ValueT, E>
+ for EnumBuilder<'lt, 'ctx, Info, Mode, E>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
{
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, Info::ValueT>,
- ) -> NativeForm<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, Info::ValueT>>>, E>
+ ) -> Canonical<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, Info::ValueT>>>, E>
where
type_name::Lowered<'value, 'ctx, Info::ValueT>: Sized,
Dynamic<type_name::Lowered<'value, 'ctx, Info::ValueT>>: DynBind<E>,
@@ -233,61 +231,71 @@ where
}
}
-impl<'ctx, Info, Mode, E: Environment> Tag<'ctx, tags::Variant, E>
- for EnumBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx: 'lt, Info, Mode: 'lt, E: Environment> Tag<'ctx, tags::Variant, E>
+ for EnumBuilder<'lt, 'ctx, Info, Mode, E>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>,
Dynamic<OwnedStatic<u32>>: DynBind<E>,
{
- fn visit<'a: 'c, 'b: 'c, 'c>(
+ fn visit<'a: 'c, 'b: 'c, 'd: 'b, 'c>(
&'a mut self,
_kind: tags::Variant,
- walker: DynWalkerObjSafe<'b, 'ctx, E>,
- ) -> NativeForm<'c, VisitResult, E> {
+ walker: DynWalkerObjSafe<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, VisitResult, E>
+ where
+ 'ctx: 'd + 'b + 'c,
+ 'lt: 'a + 'c,
+ {
let visitor = VariantVisitor::<Info, Mode, E> { marker: None };
- E::value((visitor, walker))
- .update((), |_, (visitor, walker)| {
- walker.walk(DynVisitor(visitor)).cast()
- })
- .then(self, |this, ((visitor, _), result)| {
- if let Some(variant) = visitor.marker {
- match core::mem::replace(&mut this.inner, Inner::Temp) {
- // A variant was given so we need to make the builder for
- // it.
- Inner::Seed(seed) => Info::new_builder(seed, variant)
- .map((this, result), |(this, result), builder| {
- this.inner = Inner::Builder { builder };
- result.to_done().into()
- })
- .cast::<()>(),
- inner => {
- this.inner = inner;
- E::value(result.to_done().into()).cast()
- }
- }
- } else {
- E::value(result.to_done().into()).cast()
- }
- })
- .cast()
+ E::value(visitor)
+ .update_map::<'_, '_, _, Flow>(walker, |walker, visitor| {
+ let y: DynVisitor<'_, 'lt, 'ctx, E> = DynVisitor(visitor);
+ let walker: DynWalkerObjSafe<'b, 'd, 'ctx, E> = walker;
+ let x: Canonical<'_, Flow, E> = walker.walk(y);
+ let y: Canonical<'_, Flow, E, &'_ ()> = x.cast();
+ y
+ // E::value(Flow::Done).cast()
+ });
+ // .then(self, |this, ((visitor, _), result)| {
+ // if let Some(variant) = visitor.marker {
+ // match core::mem::replace(&mut this.inner, Inner::Temp) {
+ // // A variant was given so we need to make the builder for
+ // // it.
+ // Inner::Seed(seed) => Info::new_builder(seed, variant)
+ // .map((this, result), |(this, result), builder| {
+ // this.inner = Inner::Builder { builder };
+ // result.to_done().into()
+ // })
+ // .cast::<()>(),
+ // inner => {
+ // this.inner = inner;
+ // E::value::<VisitResult>(result.to_done().into()).cast()
+ // }
+ // }
+ // } else {
+ // E::value(result.to_done().into()).cast()
+ // }
+ // });
+ // .cast()
+ todo!();
}
}
#[derive(SendSync)]
-struct VariantVisitor<'ctx, Info, Mode, E: Environment>
+struct VariantVisitor<'lt, 'ctx, Info, Mode, E: Environment>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
{
marker: Option<Info::VariantMarker>,
}
-impl<'ctx, Info, Mode, E: Environment> AnyTrait<'ctx> for VariantVisitor<'ctx, Info, Mode, E>
+impl<'lt, 'ctx: 'lt, Info, Mode: 'lt, E: Environment> AnyTrait<'lt, 'ctx> for VariantVisitor<'lt, 'ctx, Info, Mode, E>
where
E: Environment,
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
Dynamic<OwnedStatic<u32>>: DynBind<E>,
for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>,
{
@@ -314,7 +322,7 @@ where
// fn visit<'a>(
// &'a mut self,
// TempBorrowedStatic(value): TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>, E>,
-// ) -> NativeForm<'a, VisitResult<Dynamic<TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>, E>>>, E>
+// ) -> Canonical<'a, VisitResult<Dynamic<TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>, E>>>, E>
// where
// TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>, E>: Sized,
// 'ctx: 'a,
@@ -329,17 +337,17 @@ where
// }
// }
-impl<'ctx, Info, Mode, E: Environment> Value<'ctx, OwnedStatic<u32>, E>
- for VariantVisitor<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E: Environment> Value<'ctx, OwnedStatic<u32>, E>
+ for VariantVisitor<'lt, 'ctx, Info, Mode, E>
where
- Info: EnumBuildInfo<'ctx, Mode, E>,
+ Info: EnumBuildInfo<'lt, 'ctx, Mode, E>,
for<'a> Dynamic<type_name::Lowered<'a, 'ctx, OwnedStatic<u32>>>: DynBind<E>,
Dynamic<OwnedStatic<u32>>: DynBind<E>,
{
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, OwnedStatic<u32>>,
- ) -> NativeForm<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<u32>>>>, E>
+ ) -> Canonical<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<u32>>>>, E>
where
type_name::Lowered<'value, 'ctx, OwnedStatic<u32>>: Sized,
Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<u32>>>: DynBind<E>,
diff --git a/src/build/builders/core/struct.rs b/src/build/builders/core/struct.rs
index 24172b3..6e304f9 100644
--- a/src/build/builders/core/struct.rs
+++ b/src/build/builders/core/struct.rs
@@ -2,12 +2,13 @@ use core::fmt::{Debug, Display};
use effectful::{
bound::Dynamic,
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
- tri, SendSync,
+ effective::{Effective, Canonical},
+ environment::{Environment},
+ tri, SendSync, DynBind
};
use crate::{
+ trait_by_id,
any::{type_name, AnyTrait, OwnedStatic, TempBorrowedStatic},
build::BuilderTypes,
hkt::Marker,
@@ -27,17 +28,17 @@ use super::NoopVisitor;
/// A builder for a struct.
#[derive(SendSync)]
-pub struct StructBuilder<'ctx, Info, Mode, E: Environment>
+pub struct StructBuilder<'lt, 'ctx, Info, Mode, E: Environment>
where
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
{
- inner: Inner<'ctx, Info, Mode, E>,
+ inner: Inner<'lt, 'ctx, Info, Mode, E>,
}
#[derive(SendSync)]
-enum Inner<'ctx, Info, Mode, E: Environment>
+enum Inner<'lt, 'ctx, Info, Mode, E: Environment>
where
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
{
Temp,
Seed(Info::Seed),
@@ -68,7 +69,7 @@ enum StructKind {
///
/// The `Mode` generic allows implementations to change depending on the mode the user gives.
/// It is not used by the trait directly.
-pub trait StructTypeInfo<'ctx, Mode: 'ctx, E: Environment>: 'static {
+pub trait StructTypeInfo<'lt, 'ctx, Mode: 'ctx, E: Environment>: 'lt {
/// A struct of builders for each field.
type Builders: DynBind<E>;
@@ -92,12 +93,12 @@ pub trait StructTypeInfo<'ctx, Mode: 'ctx, E: Environment>: 'static {
const FIELD_COUNT: usize;
/// Create a set of builders from a seed value.
- fn new_builders<'a>(seed: Self::Seed) -> NativeForm<'a, Self::Builders, E>;
+ fn new_builders<'a>(seed: Self::Seed) -> Canonical<'a, Self::Builders, E>;
/// Finish building the struct value.
fn from_builders<'a>(
builders: Self::Builders,
- ) -> NativeForm<'a, Result<Dynamic<Self::T>, Self::Error>, E>
+ ) -> Canonical<'a, Result<Dynamic<Self::T>, Self::Error>, E>
where
Dynamic<Self::T>: DynBind<E>;
@@ -107,7 +108,7 @@ pub trait StructTypeInfo<'ctx, Mode: 'ctx, E: Environment>: 'static {
fn as_visitor<'a>(
marker: Self::FieldMarker,
builders: &'a mut Self::Builders,
- ) -> DynVisitor<'a, 'ctx, E>;
+ ) -> DynVisitor<'a, 'lt, 'ctx, E>;
/// Get a field marker from the index of the field.
///
@@ -123,49 +124,49 @@ pub trait StructTypeInfo<'ctx, Mode: 'ctx, E: Environment>: 'static {
/// Error that [`StructBuilder`] returns.
#[derive(SendSync)]
-pub struct StructError<'ctx, Info, M, E: Environment>
+pub struct StructError<'lt, 'ctx, Info, M, E: Environment>
where
- Info: StructTypeInfo<'ctx, M, E>,
+ Info: StructTypeInfo<'lt, 'ctx, M, E>,
{
/// Error from the struct info definition.
error: Info::Error,
}
-impl<'ctx, Info, Mode, E: Environment> StructError<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E: Environment> StructError<'lt, 'ctx, Info, Mode, E>
where
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
{
fn from_field_err(error: Info::Error) -> Self {
Self { error }
}
}
-impl<'ctx, Info, Mode, E: Environment> Debug for StructError<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E: Environment> Debug for StructError<'lt, 'ctx, Info, Mode, E>
where
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("StructError").field(&self.error).finish()
}
}
-impl<'ctx, Info, Mode, E: Environment> Display for StructError<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E: Environment> Display for StructError<'lt, 'ctx, Info, Mode, E>
where
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Display::fmt(&self.error, f)
}
}
-impl<'ctx, Info, Mode, E: Environment> BuilderTypes<E> for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E: Environment> BuilderTypes<E> for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
{
type Seed = Info::Seed;
- type Error = StructError<'ctx, Info, Mode, E>;
+ type Error = StructError<'lt, 'ctx, Info, Mode, E>;
type Output = Dynamic<Info::T>;
@@ -176,12 +177,12 @@ where
}
}
-impl<'ctx, Info, Mode: 'ctx, E: Environment> StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'ctx, E: Environment> StructBuilder<'lt, 'ctx, Info, Mode, E>
where
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
{
- fn make_builders<'e>(&'e mut self) -> NativeForm<'e, (), E>
+ fn make_builders<'e>(&'e mut self) -> Canonical<'e, (), E>
where
'ctx: 'e,
{
@@ -203,12 +204,11 @@ where
}
}
-impl<'ctx, Info, Mode: 'ctx, E: Environment> Builder<'ctx, E> for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'ctx, E: Environment> Builder<'lt, 'ctx, E> for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
Dynamic<OwnedStatic<String>>: DynBind<E>,
for<'a> Dynamic<&'a Info::T>: DynBind<E>,
@@ -217,7 +217,7 @@ where
for<'b, 'c> Dynamic<&'b type_name::Lowered<'b, 'c, Info::ValueT>>: DynBind<E>,
for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
{
- fn from_seed<'a>(seed: Self::Seed) -> NativeForm<'a, Self, E>
+ fn from_seed<'a>(seed: Self::Seed) -> Canonical<'a, Self, E>
where
Self: 'a,
{
@@ -227,7 +227,7 @@ where
.cast()
}
- fn build<'a>(self) -> NativeForm<'a, Result<Self::Output, Self::Error>, E>
+ fn build<'a>(self) -> Canonical<'a, Result<Self::Output, Self::Error>, E>
where
Self: 'a,
{
@@ -252,13 +252,12 @@ where
}
}
-impl<'ctx, Info, Mode: 'ctx, E: Environment> AsVisitor<'ctx, E>
- for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'ctx, E: Environment> AsVisitor<'lt, 'ctx, E>
+ for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
for<'a> Dynamic<&'a Info::T>: DynBind<E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
@@ -267,20 +266,17 @@ where
for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
for<'b, 'c> Dynamic<&'b type_name::Lowered<'b, 'c, Info::ValueT>>: DynBind<E>,
{
- fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'ctx, E>
- where
- 'ctx: 'a,
- {
+ fn as_visitor(&mut self) -> DynVisitor<'_, 'lt, 'ctx, E> {
DynVisitor(self)
}
}
-impl<'ctx, Info, Mode, E: Environment> AnyTrait<'ctx> for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx: 'lt, Info, Mode: 'lt, E: Environment> AnyTrait<'lt, 'ctx> for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
for<'a> Dynamic<&'a Info::T>: DynBind<E>,
E: Environment,
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
Dynamic<OwnedStatic<String>>: DynBind<E>,
@@ -291,6 +287,20 @@ where
Dynamic<Info::T>: DynBind<E>,
Mode: 'ctx,
{
+ fn upcast_by_id_mut<'a>(
+ &'a mut self,
+ id: crate::any::WithLtTypeId<'lt, 'ctx>,
+ ) -> Option<crate::any::MutAnyUnsized<'a, 'lt, 'ctx>>
+ where
+ 'lt: 'a,
+ {
+ dbg!(&id);
+ trait_by_id!(&mut self, id, {
+ type Impls = (dyn Tag<'ctx, tags::Map, E>, dyn Sequence<'ctx, E>);
+ });
+
+ None
+ }
}
// any_trait! {
@@ -316,10 +326,10 @@ where
// Mode: 'ctx,
// }
-impl<'ctx, Info, Mode: 'ctx, E> RequestHint<'ctx, E> for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'ctx, E> RequestHint<'ctx, E> for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
Dynamic<Info::T>: DynBind<E>,
for<'a> Dynamic<&'a Info::T>: DynBind<E>,
for<'b, 'c> Dynamic<type_name::Lowered<'b, 'c, Info::ValueT>>: DynBind<E>,
@@ -331,15 +341,15 @@ where
E: Environment,
{
#[inline(always)]
- fn request_hint<'this: 'e, 'walker: 'e, 'e>(
+ fn request_hint<'this: 'e, 'walker: 'e, 'd: 'e, 'e>(
&'this mut self,
- walker: DynWalker<'walker, 'ctx, E>,
- ) -> NativeForm<'e, VisitResult, E>
+ walker: DynWalker<'walker, 'd, 'ctx, E>,
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this + 'walker,
{
E::value((self, walker))
- .update((), |_, (this, walker)| {
+ .update_map((), |_, (this, walker)| {
// Start with a hint to use the value protocol to directly transfer the
// struct value.
hint_protocol::<dyn Value<'_, Info::ValueT, E>, _, _>(walker.cast(), *this, ())
@@ -390,16 +400,16 @@ where
/// Allows for a walker to directly give the struct value.
///
/// This skips needing to go through each field individually.
-impl<'ctx, Info, Mode, E> Value<'ctx, Info::ValueT, E> for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode, E> Value<'ctx, Info::ValueT, E> for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
E: Environment,
{
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, Info::ValueT>,
- ) -> NativeForm<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, Info::ValueT>>>, E>
+ ) -> Canonical<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, Info::ValueT>>>, E>
where
type_name::Lowered<'value, 'ctx, Info::ValueT>: Sized,
Dynamic<type_name::Lowered<'value, 'ctx, Info::ValueT>>: DynBind<E>,
@@ -416,20 +426,20 @@ where
/// Allows for the walker to use field names.
///
/// By default [`StructBuilder`] expects a tuple-like struct.
-impl<'ctx, Info, Mode: 'ctx, E> Tag<'ctx, tags::Struct, E> for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'ctx, E> Tag<'ctx, tags::Struct, E> for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
E: Environment,
{
fn visit<'this: 'e, 'walker: 'e, 'e>(
&'this mut self,
_kind: tags::Struct,
walker: DynWalkerObjSafe<'walker, 'ctx, E>,
- ) -> NativeForm<'e, VisitResult, E> {
+ ) -> Canonical<'e, VisitResult, E> {
// If this protocol is used then we need to create the builders.
E::value(self)
- .update((), |_, this| this.make_builders().cast())
+ .update_map((), |_, this| this.make_builders().cast())
.then(walker, |walker, (this, _)| {
if let Inner::Builders { kind, .. } = &mut this.inner {
// This signals to go into map mode for the sequence.
@@ -446,20 +456,20 @@ where
/// Allows for the walker to use field names.
///
/// By default [`StructBuilder`] expects a tuple-like struct.
-impl<'ctx, Info, Mode: 'ctx, E> Tag<'ctx, tags::Map, E> for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'ctx, E> Tag<'ctx, tags::Map, E> for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
E: Environment,
{
fn visit<'this: 'e, 'walker: 'e, 'e>(
&'this mut self,
_kind: tags::Map,
walker: DynWalkerObjSafe<'walker, 'ctx, E>,
- ) -> NativeForm<'e, VisitResult, E> {
+ ) -> Canonical<'e, VisitResult, E> {
// If this protocol is used then we need to create the builders.
E::value(self)
- .update((), |_, this| this.make_builders().cast())
+ .update_map((), |_, this| this.make_builders().cast())
.then(walker, |walker, (this, _)| {
if let Inner::Builders { kind, .. } = &mut this.inner {
// This signals to go into map mode for the sequence.
@@ -479,10 +489,10 @@ where
///
/// If the [`tags::Struct`] or [`tags::Map`] tags are used then this will expect
/// a sequence of key value pairs. Where the key is the field name.
-impl<'ctx, Info, Mode: 'ctx, E> Sequence<'ctx, E> for StructBuilder<'ctx, Info, Mode, E>
+impl<'lt, 'ctx, Info, Mode: 'ctx, E> Sequence<'ctx, E> for StructBuilder<'lt, 'ctx, Info, Mode, E>
where
Self: DynBind<E>,
- Info: StructTypeInfo<'ctx, Mode, E>,
+ Info: StructTypeInfo<'lt, 'ctx, Mode, E>,
for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
Dynamic<OwnedStatic<String>>: DynBind<E>,
@@ -492,14 +502,14 @@ where
fn visit<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
scope: DynSequenceScope<'b, 'ctx, E>,
- ) -> NativeForm<'c, VisitResult, E>
+ ) -> Canonical<'c, VisitResult, E>
where
'ctx: 'a + 'b + 'c,
{
// If this protocol is used then we need to create the builders.
E::value(self)
- .update((), |_, this| this.make_builders().cast())
- .update(scope, |scope, (this, _)| {
+ .update_map((), |_, this| this.make_builders().cast())
+ .update_map(scope, |scope, (this, _)| {
match &mut this.inner {
// We should treat the sequence as just values.
Inner::Builders {
@@ -526,8 +536,7 @@ where
.next(visitor)
.map((), |_, x| Flow::to_control_flow(x))
.cast()
- })
- .map((), |_, (_, _, x)| x)
+ }, (), | _, _, _, x| x)
.cast::<()>()
}
// We should treat the sequence as key value pairs.
@@ -552,8 +561,7 @@ where
.next(DynVisitor(visitor))
.map((), |_, x| Flow::to_control_flow(x))
.cast()
- })
- .map((), |_, (_, _, x)| x)
+ }, (), |_, _, _, x| x)
.cast()
}
// If we don't have the builders ... we can't do anything.
@@ -570,22 +578,39 @@ where
}
#[derive(SendSync)]
-struct FieldVisitor<'a, 'ctx, I: StructTypeInfo<'ctx, M, E>, M, E: Environment> {
+struct FieldVisitor<'a, 'lt, 'ctx, I: StructTypeInfo<'lt, 'ctx, M, E>, M, E: Environment> {
builders: &'a mut I::Builders,
marker: Option<I::FieldMarker>,
_marker: Marker<E>,
}
-impl<'a, 'ctx, I: StructTypeInfo<'ctx, M, E>, M, E: Environment> AnyTrait<'ctx>
- for FieldVisitor<'a, 'ctx, I, M, E>
+impl<'e, 'lt: 'e, 'ctx: 'lt, I: StructTypeInfo<'lt, 'ctx, M, E>, M: 'lt, E: Environment> AnyTrait<'e, 'ctx>
+ for FieldVisitor<'e, 'lt, 'ctx, I, M, E>
where
E: Environment,
- I: StructTypeInfo<'ctx, M, E>,
+ I: StructTypeInfo<'lt, 'ctx, M, E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
Dynamic<OwnedStatic<String>>: DynBind<E>,
for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
{
+ fn upcast_by_id_mut<'a>(
+ &'a mut self,
+ id: crate::any::WithLtTypeId<'e, 'ctx>,
+ ) -> Option<crate::any::MutAnyUnsized<'a, 'e, 'ctx>>
+ where
+ 'e: 'a
+ {
+ dbg!(&id);
+ trait_by_id!(&mut self, id, {
+ type Impls = (dyn Tag<'ctx, tags::Key, E>);
+ });
+
+ self.marker.and_then(|marker| {
+ let x = I::as_visitor(marker, self.builders).0;
+ x.upcast_by_id_mut(id)
+ })
+ }
}
// any_trait! {
@@ -610,10 +635,10 @@ where
// for<'b> Dynamic<TempBorrowedStatic<'b, str>>: DynBind<E>,
// }
-impl<'d, 'ctx, I, M, E> Tag<'ctx, tags::Key, E> for FieldVisitor<'d, 'ctx, I, M, E>
+impl<'d, 'lt, 'ctx, I, M, E> Tag<'ctx, tags::Key, E> for FieldVisitor<'d, 'lt, 'ctx, I, M, E>
where
E: Environment,
- I: StructTypeInfo<'ctx, M, E>,
+ I: StructTypeInfo<'lt, 'ctx, M, E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
Dynamic<OwnedStatic<String>>: DynBind<E>,
@@ -623,14 +648,14 @@ where
&'a mut self,
_key: tags::Key,
walker: DynWalkerObjSafe<'b, 'ctx, E>,
- ) -> NativeForm<'c, VisitResult, E> {
+ ) -> Canonical<'c, VisitResult, E> {
let visitor = NameVisitor::<I, M, E> {
field_marker: None,
_marker: Default::default(),
};
E::value((self, visitor, walker))
- .update((), |_, (_, visitor, walker)| {
+ .update_map((), |_, (_, visitor, walker)| {
walker.walk(DynVisitor(visitor)).cast()
})
.map((), |_, ((this, visitor, _), flow)| {
@@ -642,16 +667,16 @@ where
}
#[derive(SendSync)]
-struct NameVisitor<'ctx, I: StructTypeInfo<'ctx, M, E>, M, E: Environment> {
+struct NameVisitor<'lt, 'ctx, I: StructTypeInfo<'lt, 'ctx, M, E>, M, E: Environment> {
field_marker: Option<I::FieldMarker>,
_marker: Marker<E>,
}
-impl<'ctx, I: StructTypeInfo<'ctx, M, E>, M, E: Environment> AnyTrait<'ctx>
- for NameVisitor<'ctx, I, M, E>
+impl<'lt, 'ctx: 'lt, I: StructTypeInfo<'lt, 'ctx, M, E>, M: 'lt, E: Environment> AnyTrait<'lt, 'ctx>
+ for NameVisitor<'lt, 'ctx, I, M, E>
where
E: Environment,
- I: StructTypeInfo<'ctx, M, E>,
+ I: StructTypeInfo<'lt, 'ctx, M, E>,
Dynamic<OwnedStatic<usize>>: DynBind<E>,
Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
Dynamic<OwnedStatic<String>>: DynBind<E>,
@@ -674,15 +699,15 @@ where
// for<'a> Dynamic<TempBorrowedStatic<'a, str>>: DynBind<E>,
// }
-impl<'ctx, I, M, E> Value<'ctx, OwnedStatic<usize>, E> for NameVisitor<'ctx, I, M, E>
+impl<'lt, 'ctx, I, M, E> Value<'ctx, OwnedStatic<usize>, E> for NameVisitor<'lt, 'ctx, I, M, E>
where
E: Environment,
- I: StructTypeInfo<'ctx, M, E>,
+ I: StructTypeInfo<'lt, 'ctx, M, E>,
{
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, OwnedStatic<usize>>,
- ) -> NativeForm<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<usize>>>>, E>
+ ) -> Canonical<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<usize>>>>, E>
where
type_name::Lowered<'value, 'ctx, OwnedStatic<usize>>: Sized,
Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<usize>>>: DynBind<E>,
@@ -703,7 +728,7 @@ where
// fn visit<'a>(
// &'a mut self,
// TempBorrowedStatic(name): TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>, E>,
-// ) -> NativeForm<'a, VisitResult<Dynamic<TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>, E>>>, E>
+// ) -> Canonical<'a, VisitResult<Dynamic<TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>, E>>>, E>
// where
// TypeName::T<'a, 'ctx, TempBorrowedStaticHrt<str>, E>: Sized,
// 'ctx: 'a,
@@ -714,16 +739,16 @@ where
// }
// }
-impl<'ctx, I, M, E> Value<'ctx, OwnedStatic<&'static str>, E> for NameVisitor<'ctx, I, M, E>
+impl<'lt, 'ctx, I, M, E> Value<'ctx, OwnedStatic<&'static str>, E> for NameVisitor<'lt, 'ctx, I, M, E>
where
E: Environment,
- I: StructTypeInfo<'ctx, M, E>,
+ I: StructTypeInfo<'lt, 'ctx, M, E>,
Dynamic<OwnedStatic<&'static str>>: DynBind<E>,
{
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, OwnedStatic<&'static str>>,
- ) -> NativeForm<
+ ) -> Canonical<
'e,
VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<&'static str>>>>,
E,
@@ -739,16 +764,16 @@ where
}
}
-impl<'ctx, I, M, E> Value<'ctx, OwnedStatic<String>, E> for NameVisitor<'ctx, I, M, E>
+impl<'lt, 'ctx, I, M, E> Value<'ctx, OwnedStatic<String>, E> for NameVisitor<'lt, 'ctx, I, M, E>
where
E: Environment,
- I: StructTypeInfo<'ctx, M, E>,
+ I: StructTypeInfo<'lt, 'ctx, M, E>,
Dynamic<OwnedStatic<String>>: DynBind<E>,
{
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, OwnedStatic<String>>,
- ) -> NativeForm<
+ ) -> Canonical<
'e,
VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<String>>>>,
E,
diff --git a/src/build/builders/core/value.rs b/src/build/builders/core/value.rs
index 310e337..ad445bb 100644
--- a/src/build/builders/core/value.rs
+++ b/src/build/builders/core/value.rs
@@ -2,8 +2,9 @@ use core::fmt::Display;
use effectful::{
bound::Dynamic,
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
+ DynBind,
SendSync,
};
@@ -70,19 +71,19 @@ where
}
}
-impl<'ctx, T: 'static, Clone, E: Environment> crate::Builder<'ctx, E> for ValueBuilder<T, Clone, E>
+impl<'lt, 'ctx: 'lt, T: 'static, Clone, E: Environment> crate::Builder<'lt, 'ctx, E> for ValueBuilder<T, Clone, E>
where
Dynamic<T>: DynBind<E>,
- Self: AnyTrait<'ctx>,
+ Self: AnyTrait<'lt, 'ctx>,
{
- fn build<'a>(self) -> NativeForm<'a, Result<Self::Output, Self::Error>, E>
+ fn build<'a>(self) -> Canonical<'a, Result<Self::Output, Self::Error>, E>
where
Self: 'a,
{
E::value(self.value.ok_or(ValueError(Default::default()))).cast()
}
- fn from_seed<'a>(_seed: Self::Seed) -> NativeForm<'a, Self, E>
+ fn from_seed<'a>(_seed: Self::Seed) -> Canonical<'a, Self, E>
where
Self: 'a,
{
@@ -94,41 +95,38 @@ where
}
}
-impl<'ctx, T: 'static, Clone, E: Environment> AsVisitor<'ctx, E> for ValueBuilder<T, Clone, E>
+impl<'lt, 'ctx: 'lt, T: 'static, Clone, E: Environment> AsVisitor<'lt, 'ctx, E> for ValueBuilder<T, Clone, E>
where
- Self: AnyTrait<'ctx> + DynBind<E>,
+ Self: AnyTrait<'lt, 'ctx> + DynBind<E>,
{
- fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'ctx, E>
- where
- 'ctx: 'a,
- {
+ fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'lt, 'ctx, E> {
DynVisitor(self)
}
}
-impl<'ctx, T: 'static, E: Environment> AnyTrait<'ctx> for ValueBuilder<T, NotCloneable, E>
+impl<'lt, 'ctx: 'lt, T: 'static, E: Environment> AnyTrait<'lt, 'ctx> for ValueBuilder<T, NotCloneable, E>
where
Dynamic<T>: DynBind<E>,
for<'a> Dynamic<&'a T>: DynBind<E>,
Dynamic<OwnedStatic<T>>: DynBind<E>,
for<'a> Dynamic<&'a OwnedStatic<T>>: DynBind<E>,
{
- fn upcast_by_id_mut<'a, 'lt: 'a>(
+ fn upcast_by_id_mut<'a>(
&'a mut self,
id: crate::any::WithLtTypeId<'lt, 'ctx>,
- ) -> Option<crate::any::MutAnyUnsized<'a, 'lt, 'ctx>>
+ ) -> Option<crate::any::MutAnyUnsized<'a, 'lt, 'ctx>>
where
- 'ctx: 'lt,
+ 'lt: 'a
{
trait_by_id!(&mut self, id, {
- type Impls<'lt, 'ctx> = (dyn RequestHint<'ctx, E>, dyn Value<'ctx, OwnedStatic<T>, E>);
+ type Impls = (dyn RequestHint<'ctx, E>, dyn Value<'ctx, OwnedStatic<T>, E>);
+ });
- None
- })
+ None
}
}
-impl<'ctx, T: 'static + Clone, E: Environment> AnyTrait<'ctx> for ValueBuilder<T, Cloneable, E>
+impl<'lt, 'ctx: 'lt, T: 'static + Clone, E: Environment> AnyTrait<'lt, 'ctx> for ValueBuilder<T, Cloneable, E>
where
Dynamic<T>: DynBind<E>,
for<'a> Dynamic<&'a T>: DynBind<E>,
@@ -143,19 +141,19 @@ where
for<'a> Dynamic<TempBorrowedMutStatic<'a, T>>: DynBind<E>,
for<'a> Dynamic<&'a TempBorrowedMutStatic<'a, T>>: DynBind<E>,
{
- fn upcast_by_id_mut<'a, 'lt: 'a>(
+ fn upcast_by_id_mut<'a>(
&'a mut self,
id: crate::any::WithLtTypeId<'lt, 'ctx>,
) -> Option<crate::any::MutAnyUnsized<'a, 'lt, 'ctx>>
where
- 'ctx: 'lt,
+ 'lt: 'a,
{
dbg!(&id);
trait_by_id!(&mut self, id, {
- type Impls<'lt, 'ctx> = (dyn RequestHint<'ctx, E>, dyn Value<'ctx, OwnedStatic<T>, E>);
+ type Impls = (dyn RequestHint<'ctx, E>, dyn Value<'ctx, OwnedStatic<T>, E>);
+ });
- None
- })
+ None
}
}
@@ -204,14 +202,15 @@ where
Dynamic<OwnedStatic<T>>: DynBind<E>,
for<'a> Dynamic<&'a OwnedStatic<T>>: DynBind<E>,
{
- fn request_hint<'this: 'e, 'walker: 'e, 'e>(
+ fn request_hint<'this: 'e, 'walker: 'e, 'lt: 'e, 'e>(
&'this mut self,
- walker: DynWalker<'walker, 'ctx, E>,
- ) -> NativeForm<'e, VisitResult, E>
+ walker: DynWalker<'walker, 'lt, 'ctx, E>,
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this + 'walker,
{
- E::with((self, walker), |(this, walker)| {
+ E::value((self, walker))
+ .update_map((), |_, (this, walker)| {
hint_protocol::<dyn Value<'_, OwnedStatic<T>, E>, _, _>(walker.cast(), *this, ()).cast()
})
.map((), |_, (_, x)| x)
@@ -235,15 +234,15 @@ where
for<'a> Dynamic<TempBorrowedMutStatic<'a, T>>: DynBind<E>,
for<'a> Dynamic<&'a TempBorrowedMutStatic<'a, T>>: DynBind<E>,
{
- fn request_hint<'this: 'e, 'walker: 'e, 'e>(
+ fn request_hint<'this: 'e, 'walker: 'e, 'lt: 'e, 'e>(
&'this mut self,
- walker: DynWalker<'walker, 'ctx, E>,
- ) -> NativeForm<'e, VisitResult, E>
+ walker: DynWalker<'walker, 'lt, 'ctx, E>,
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this + 'walker,
{
E::value((self, walker))
- .update((), |_, (this, walker)| {
+ .update_map((), |_, (this, walker)| {
hint_protocol::<dyn Value<'_, OwnedStatic<T>, E>, _, _>(walker.cast(), *this, ())
.cast()
})
@@ -297,7 +296,7 @@ where
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, OwnedStatic<T>>,
- ) -> NativeForm<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<T>>>>, E>
+ ) -> Canonical<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<T>>>>, E>
where
type_name::Lowered<'value, 'ctx, OwnedStatic<T>>: Sized,
Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<T>>>: DynBind<E>,
@@ -324,7 +323,7 @@ where
'ctx,
type_name::Raised<'static, 'ctx, BorrowedStatic<'ctx, T>>,
>,
- ) -> NativeForm<
+ ) -> Canonical<
'e,
VisitResult<
Dynamic<
@@ -366,7 +365,7 @@ where
// fn visit<'a>(
// &'a mut self,
// TempBorrowedStatic(value): TempBorrowedStatic<'a, T>,
-// ) -> NativeForm<'a, VisitResult<Dynamic<TempBorrowedStatic<'a, T>>>, E>
+// ) -> Canonical<'a, VisitResult<Dynamic<TempBorrowedStatic<'a, T>>>, E>
// where
// 'ctx: 'a,
// {
@@ -386,7 +385,7 @@ where
// fn visit<'a>(
// &'a mut self,
// BorrowedMutStatic(value): BorrowedMutStatic<'ctx, T>,
-// ) -> NativeForm<'a, VisitResult<Dynamic<BorrowedMutStatic<'ctx, T>>>, E>
+// ) -> Canonical<'a, VisitResult<Dynamic<BorrowedMutStatic<'ctx, T>>>, E>
// where
// 'ctx: 'a,
// {
@@ -407,7 +406,7 @@ where
// fn visit<'a>(
// &'a mut self,
// TempBorrowedMutStatic(value): TempBorrowedMutStatic<'a, T>,
-// ) -> NativeForm<'a, VisitResult<Dynamic<TempBorrowedMutStatic<'a, T>>>, E>
+// ) -> Canonical<'a, VisitResult<Dynamic<TempBorrowedMutStatic<'a, T>>>, E>
// where
// 'ctx: 'a,
// {
diff --git a/src/macros/build.rs b/src/macros/build.rs
index 49dc396..132a4f4 100644
--- a/src/macros/build.rs
+++ b/src/macros/build.rs
@@ -11,9 +11,9 @@ macro_rules! Build {
// add a module here to seal fields.
impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Build<'ctx, M, E> for $name
where
- effectful::bound::Dynamic<$name>: effectful::environment::DynBind<E>,
+ effectful::bound::Dynamic<$name>: effectful::bound::DynBind<E>,
$($type: $crate::Build<'ctx, M, E>,)*
- $(effectful::bound::Dynamic<$type>: effectful::environment::DynBind<E>,)*
+ $(effectful::bound::Dynamic<$type>: effectful::bound::DynBind<E>,)*
$crate::build::builders::core::r#struct::StructBuilder<'ctx, __Info, M, E>: $crate::Builder<'ctx, E, Value = Self>
{
type Builder = $crate::build::builders::core::r#struct::StructBuilder<'ctx, __Info, M, E>;
@@ -83,9 +83,9 @@ macro_rules! Build {
impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::build::builders::core::r#struct::StructTypeInfo<'ctx, M, E> for __Info
where
- effectful::bound::Dynamic<$name>: effectful::environment::DynBind<E>,
+ effectful::bound::Dynamic<$name>: effectful::bound::DynBind<E>,
$($type: $crate::Build<'ctx, M, E>,)*
- $(effectful::bound::Dynamic<$type>: effectful::environment::DynBind<E>),*
+ $(effectful::bound::Dynamic<$type>: effectful::bound::DynBind<E>),*
{
type Builders = Builders<'ctx, M, E>;
type FieldMarker = Field;
@@ -99,13 +99,14 @@ macro_rules! Build {
};
#[inline(always)]
- fn new_builders<'a>(seed: Self::Seed) -> effectful::environment::NativeForm<'a, Self::Builders, E> {
+ fn new_builders<'a>(seed: Self::Seed) -> effectful::effective::Canonical<'a, Self::Builders, E> {
let ($($field),*) = seed;
use effectful::effective::Effective;
+ use effectful::join;
- effectful::effective::join(
- ($(<<$type as $crate::Build<'ctx, M, E>>::Builder as $crate::Builder::<E>>::from_seed($field),)*)
+ ::effectful::join!(
+ $(#[capture($field)] || <<$type as $crate::Build<'ctx, M, E>>::Builder as $crate::Builder::<E>>::from_seed($field),)*
).map((), |_, ($($field,)*)| {
Builders {
$($field),*
@@ -114,16 +115,19 @@ macro_rules! Build {
.cast()
}
- fn from_builders<'a>(builders: Self::Builders) -> effectful::environment::NativeForm<'a, Result<effectful::bound::Dynamic<Self::T>, Self::Error>, E> {
+ fn from_builders<'a>(builders: Self::Builders) -> effectful::effective::Canonical<'a, Result<effectful::bound::Dynamic<Self::T>, Self::Error>, E> {
use $crate::Builder;
use effectful::effective::Effective;
use $crate::build::BuilderTypes;
+ use effectful::try_join;
- effectful::effective::try_join(
- (
- $(builders.$field.build().map((), |_, x| x.map(|x| effectful::bound::Dynamic(<<$type as Build<'ctx, M, E>>::Builder as BuilderTypes<E>>::unwrap_output(x))).map_err(Error::$field)),)*
- )
+ let Builders {
+ $($field),*
+ } = builders;
+
+ ::effectful::try_join!(
+ $(#[capture($field)] || $field.build().map((), |_, x| x.map(|x| effectful::bound::Dynamic(<<$type as Build<'ctx, M, E>>::Builder as BuilderTypes<E>>::unwrap_output(x))).map_err(Error::$field)),)*
).map((), |_, result| match result {
Ok(($(effectful::bound::Dynamic($field),)*)) => Ok(effectful::bound::Dynamic($name {
$($field),*
@@ -175,7 +179,7 @@ macro_rules! Build {
// add a module here to seal fields.
impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Build<'ctx, M, E> for $name
where
- effectful::bound::Dynamic<$name>: effectful::environment::DynBind<E>,
+ effectful::bound::Dynamic<$name>: effectful::bound::DynBind<E>,
$($value: $crate::Build<'ctx, M, E>,)*
$(<<$value as Build<'ctx, M, E>>::Builder as BuilderTypes<E>>::Seed: Default,)*
$crate::build::builders::core::r#enum::EnumBuilder<'ctx, __Info, M, E>: $crate::Builder<'ctx, E, Value = Self>
@@ -272,7 +276,7 @@ macro_rules! Build {
impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::build::builders::core::r#enum::EnumBuildInfo<'ctx, M, E> for __Info
where
- effectful::bound::Dynamic<$name>: effectful::environment::DynBind<E>,
+ effectful::bound::Dynamic<$name>: effectful::bound::DynBind<E>,
$($value: $crate::Build<'ctx, M, E>,)*
$(<<$value as Build<'ctx, M, E>>::Builder as BuilderTypes<E>>::Seed: Default),*
{
@@ -291,7 +295,7 @@ macro_rules! Build {
fn new_builder<'a>(
seed: Self::Seed,
variant: Self::VariantMarker,
- ) -> NativeForm<'a, Self::Builders, E> {
+ ) -> Canonical<'a, Self::Builders, E> {
match variant {
$(__Marker::$variant => {
Builder::<E>::from_seed(Default::default()).map((), |_, builder| __Builders::$variant(builder)).cast()
@@ -301,13 +305,13 @@ macro_rules! Build {
fn finish_builder<'a>(
builder: Self::Builders,
- ) -> NativeForm<'a, Result<effectful::bound::Dynamic<Self::T>, Self::Error>, E> {
+ ) -> Canonical<'a, Result<effectful::bound::Dynamic<Self::T>, Self::Error>, E> {
match builder {
$(__Builders::$variant(builder) => builder.build().map((), |_, value| value.map(|x| effectful::bound::Dynamic($name::$variant(<<$value as Build<'ctx, M, E>>::Builder as BuilderTypes<E>>::unwrap_output(x)))).map_err(__Error::$variant)).cast()),*
}
}
- fn from_value<'a>(value: TypeName::T<'a, 'ctx, Self::ValueT, E>) -> Self::T {
+ fn from_value<'a>(value: $crate::any::type_name::Lowered<'a, 'ctx, Self::ValueT, E>) -> Self::T {
value.0
}
@@ -334,8 +338,8 @@ macro_rules! Build {
fn guess_variant<'a>(
seed: Self::Seed,
scope: DynRecoverableScope<'a, 'ctx, E>,
- ) -> NativeForm<'a, Result<effectful::bound::Dynamic<Self::T>, Self::Error>, E> {
- use effectful::effective::EffectiveExt;
+ ) -> Canonical<'a, Result<effectful::bound::Dynamic<Self::T>, Self::Error>, E> {
+ use effectful::effective::Effective;
use effectful::short::ResultErrorExt;
E::value((scope, Err(__ErrorBuilder::<M, E> { A: None, B: None })))
@@ -344,7 +348,7 @@ macro_rules! Build {
<<$value as Build<M, E>>::Builder as Builder<_>>::from_seed(Default::default())
.map(scope, |scope, builder| (scope, builder))
- .update((), |(), (scope, builder)| scope.new_walk(builder.as_visitor()).cast())
+ .update_map((), |(), (scope, builder)| scope.new_walk(builder.as_visitor()).cast())
.then((), |(), ((_, builder), _)| builder.build())
.map(error, |mut error, result| {
result.map(|x| effectful::bound::Dynamic(X::$variant(
diff --git a/src/protocol.rs b/src/protocol.rs
index b330750..467cee7 100644
--- a/src/protocol.rs
+++ b/src/protocol.rs
@@ -57,102 +57,81 @@ pub mod walker;
use core::ops::{Deref, DerefMut};
-use effectful::{environment::Environment, SendSync};
+use effectful::{bound::SsBound, DynBind, SendSync};
use crate::any::AnyTrait;
-use effectful::environment::DynBind;
-use effectful::environment::EnvConfig;
-pub trait AnyTraitDynBind<'a, 'ctx, E: EnvConfig>: AnyTrait<'ctx> + DynBind<E> {
- fn cast(&self) -> &(dyn AnyTrait<'ctx> + 'a);
- fn cast_mut(&mut self) -> &mut (dyn AnyTrait<'ctx> + 'a);
- fn cast_mut2(&mut self) -> &mut dyn AnyTrait<'ctx>;
-
- fn cast_bind_mut<'b>(&'b mut self) -> &'b mut (dyn AnyTraitDynBind<'b, 'ctx, E> + 'b)
- where
- 'a: 'b;
+pub trait AnyTraitDynBind<'lt, 'ctx: 'lt, E: SsBound + 'lt>: AnyTrait<'lt, 'ctx> + DynBind<E> + 'lt {
+ fn cast(&self) -> &(dyn AnyTrait<'lt, 'ctx> + 'lt);
+ fn cast_mut(&mut self) -> &mut (dyn AnyTrait<'lt, 'ctx> + 'lt);
}
-impl<'a, 'ctx, E: EnvConfig, T> AnyTraitDynBind<'a, 'ctx, E> for T
+impl<'lt, 'ctx, E, T> AnyTraitDynBind<'lt, 'ctx, E> for T
where
- T: AnyTrait<'ctx> + DynBind<E> + 'a,
+ E: SsBound + 'lt,
+ T: AnyTrait<'lt, 'ctx> + DynBind<E> + 'lt,
+ 'ctx: 'lt,
{
- fn cast(&self) -> &(dyn AnyTrait<'ctx> + 'a) {
- self
- }
-
- fn cast_mut(&mut self) -> &mut (dyn AnyTrait<'ctx> + 'a) {
- self
- }
-
- fn cast_mut2(&mut self) -> &mut dyn AnyTrait<'ctx> {
+ fn cast(&self) -> &(dyn AnyTrait<'lt, 'ctx> + 'lt) {
self
}
- fn cast_bind_mut<'b>(&'b mut self) -> &'b mut (dyn AnyTraitDynBind<'b, 'ctx, E> + 'b)
- where
- 'a: 'b,
- {
+ fn cast_mut(&mut self) -> &mut (dyn AnyTrait<'lt, 'ctx> + 'lt) {
self
}
}
#[derive(SendSync)]
-pub struct DynVisitor<'a, 'ctx, E: EnvConfig>(pub &'a mut (dyn AnyTraitDynBind<'a, 'ctx, E> + 'a));
+pub struct DynVisitor<'a, 'lt, 'ctx, E: SsBound>(pub &'a mut (dyn AnyTraitDynBind<'lt, 'ctx, E> + 'lt));
-impl<'a, 'ctx, E: EnvConfig> DynVisitor<'a, 'ctx, E> {
- pub fn cast<'b>(&'b mut self) -> DynVisitor<'b, 'ctx, E> {
- DynVisitor(self.0.cast_bind_mut())
+impl<'a, 'lt, 'ctx, E: SsBound> DynVisitor<'a, 'lt, 'ctx, E> {
+ pub fn cast(&mut self) -> DynVisitor<'_, 'lt, 'ctx, E> {
+ DynVisitor(self.0)
}
}
-impl<'a, 'ctx, E: EnvConfig> Deref for DynVisitor<'a, 'ctx, E> {
- type Target = dyn AnyTrait<'ctx> + 'a;
+impl<'a, 'lt, 'ctx, E: SsBound> Deref for DynVisitor<'a, 'lt, 'ctx, E> {
+ type Target = dyn AnyTrait<'lt, 'ctx> + 'lt;
fn deref(&self) -> &Self::Target {
self.0.cast()
}
}
-impl<'a, 'ctx, E: EnvConfig> DerefMut for DynVisitor<'a, 'ctx, E> {
+impl<'a, 'lt, 'ctx, E: SsBound> DerefMut for DynVisitor<'a, 'lt, 'ctx, E> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.0.cast_mut()
}
}
-pub trait AsVisitor<'ctx, E: EnvConfig> {
- fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'ctx, E>
- where
- 'ctx: 'a;
+pub trait AsVisitor<'lt, 'ctx, E: SsBound> {
+ fn as_visitor(&mut self) -> DynVisitor<'_, 'lt, 'ctx, E>;
}
-impl<'b, 'ctx, E: EnvConfig> AsVisitor<'ctx, E> for DynVisitor<'b, 'ctx, E> {
- fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'ctx, E>
- where
- 'ctx: 'a,
- {
+impl<'a, 'lt, 'ctx, E: SsBound> AsVisitor<'lt, 'ctx, E> for DynVisitor<'a, 'lt, 'ctx, E> {
+ fn as_visitor(&mut self) -> DynVisitor<'_, 'lt, 'ctx, E> {
self.cast()
}
}
#[derive(SendSync)]
-pub struct DynWalker<'a, 'ctx, E: EnvConfig>(pub &'a mut (dyn AnyTraitDynBind<'a, 'ctx, E> + 'a));
+pub struct DynWalker<'a, 'lt, 'ctx, E: SsBound>(pub &'a mut (dyn AnyTraitDynBind<'lt, 'ctx, E> + 'lt));
-impl<'a, 'ctx, E: EnvConfig> DynWalker<'a, 'ctx, E> {
- pub fn cast<'b>(&'b mut self) -> DynWalker<'b, 'ctx, E> {
- DynWalker(self.0.cast_bind_mut())
+impl<'a, 'lt, 'ctx, E: SsBound> DynWalker<'a, 'lt, 'ctx, E> {
+ pub fn cast(&mut self) -> DynWalker<'_, 'lt, 'ctx, E> {
+ DynWalker(self.0)
}
}
-impl<'a, 'ctx, E: EnvConfig> Deref for DynWalker<'a, 'ctx, E> {
- type Target = dyn AnyTrait<'ctx> + 'a;
+impl<'a, 'lt, 'ctx, E: SsBound> Deref for DynWalker<'a, 'lt, 'ctx, E> {
+ type Target = dyn AnyTrait<'lt, 'ctx> + 'lt;
fn deref(&self) -> &Self::Target {
self.0.cast()
}
}
-impl<'a, 'ctx, E: EnvConfig> DerefMut for DynWalker<'a, 'ctx, E> {
+impl<'a, 'lt, 'ctx, E: SsBound> DerefMut for DynWalker<'a, 'lt, 'ctx, E> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.0.cast_mut()
}
diff --git a/src/protocol/visitor.rs b/src/protocol/visitor.rs
index a00f666..feb9c02 100644
--- a/src/protocol/visitor.rs
+++ b/src/protocol/visitor.rs
@@ -1,3 +1,5 @@
+use core::ops::ControlFlow;
+
use crate::{Flow, Status};
mod recoverable;
@@ -7,10 +9,7 @@ mod tag;
mod value;
use effectful::{
- bound::HasSendAndSync,
- effective::{Effective, SplitUpdateEffective},
- environment::{DynBind, Environment, InEnvironment, NativeForm},
- SendSync,
+ bound::HasSendAndSync, effective::{Canonical, Effective, UpdatePartial}, environment::{Environment, InEnvironment}, DynBind, SendSync
};
pub use recoverable::*;
pub use request_hint::*;
@@ -91,7 +90,7 @@ impl<S> VisitResult<S> {
}
}
-pub type IfSkippedEffective<'ctx, 'lt, 'wrap, Cap, Update, Eff> = SplitUpdateEffective<
+pub type IfSkippedEffective<'ctx, 'lt, 'wrap, Cap, Update, Eff> = UpdatePartial<
'wrap,
'lt,
(),
@@ -102,12 +101,14 @@ pub type IfSkippedEffective<'ctx, 'lt, 'wrap, Cap, Update, Eff> = SplitUpdateEff
Cap,
&'a mut Update,
)
- -> NativeForm<'a, VisitResult<()>, <Eff as InEnvironment>::Env, &'ctx ()>,
+ -> Canonical<'a, VisitResult<()>, <Eff as InEnvironment>::Env, &'ctx ()>,
>,
),
+ (),
Update,
+ (),
VisitResult<()>,
- VisitResult<()>,
+ (Update, VisitResult<()>),
Eff,
>;
@@ -115,7 +116,7 @@ type IfSkippedF<'ctx, Cap, Update, Eff> =
for<'a> fn(
Cap,
&'a mut Update,
- ) -> NativeForm<'a, VisitResult<()>, <Eff as InEnvironment>::Env, &'ctx ()>;
+ ) -> Canonical<'a, VisitResult<()>, <Eff as InEnvironment>::Env, &'ctx ()>;
pub trait EffectiveVisitExt<'lt>: Effective<'lt> {
fn if_skipped<'ctx, 'wrap, Cap, Update>(
@@ -130,14 +131,16 @@ pub trait EffectiveVisitExt<'lt>: Effective<'lt> {
'ctx: 'lt,
'lt: 'wrap,
{
- self.split_update(
+ self.update_partial(
(),
- |_, x| x,
- (cap, HasSendAndSync(f)),
- |(cap, HasSendAndSync(f)), update, value| match value {
- VisitResult::Skipped(()) => f(cap, update),
- _ => Self::Env::value(value).cast(),
+ |_, (update, result)| match result {
+ VisitResult::Skipped(()) => (update, ControlFlow::Continue(())),
+ VisitResult::Control(_) => (update, ControlFlow::Break(result)),
},
+ (cap, HasSendAndSync(f)),
+ |(cap, HasSendAndSync(f)), update, ()| f(cap, update),
+ (),
+ |_, update, out| (update, out)
)
}
@@ -153,14 +156,16 @@ pub trait EffectiveVisitExt<'lt>: Effective<'lt> {
'ctx: 'lt,
'lt: 'wrap,
{
- self.split_update(
+ self.update_partial(
(),
- |_, x| x,
- (cap, HasSendAndSync(f)),
- |(cap, HasSendAndSync(f)), update, value| match value {
- VisitResult::Skipped(()) | VisitResult::Control(Flow::Continue) => f(cap, update),
- _ => Self::Env::value(value).cast(),
+ |_, (update, result)| match result {
+ VisitResult::Skipped(()) | VisitResult::Control(Flow::Continue) => (update, ControlFlow::Continue(())),
+ VisitResult::Control(_) => (update, ControlFlow::Break(result)),
},
+ (cap, HasSendAndSync(f)),
+ |(cap, HasSendAndSync(f)), update, ()| f(cap, update),
+ (),
+ |_, update, out| (update, out)
)
}
}
diff --git a/src/protocol/visitor/recoverable.rs b/src/protocol/visitor/recoverable.rs
index 7ad36bf..f1a597f 100644
--- a/src/protocol/visitor/recoverable.rs
+++ b/src/protocol/visitor/recoverable.rs
@@ -1,8 +1,5 @@
use effectful::{
- effective::Effective,
- environment::{DynBind, EnvConfig, Environment, InEnvironment, NativeForm},
- higher_ranked::Rank1,
- SendSync,
+ effective::{Canonical, Effective}, environment::{Environment, InEnvironment}, higher_ranked::Rank1, DynBind, SendSync
};
use crate::{
@@ -18,7 +15,7 @@ pub trait Recoverable<'ctx, E: Environment>: DynBind<E> {
fn visit<'a>(
&'a mut self,
scope: DynRecoverableScope<'a, 'ctx, E>,
- ) -> NativeForm<'a, VisitResult, E>;
+ ) -> Canonical<'a, VisitResult, E>;
}
const _: () = {
@@ -46,22 +43,22 @@ const _: () = {
};
pub trait RecoverableScope<'ctx, E: Environment>: DynBind<E> {
- fn new_walk<'this: 'effect, 'visitor: 'effect, 'effect>(
+ fn new_walk<'this: 'effect, 'visitor: 'effect, 'lt: 'effect, 'effect>(
&'this mut self,
- visitor: DynVisitor<'visitor, 'ctx, E>,
- ) -> NativeForm<'effect, Status, E>;
+ visitor: DynVisitor<'visitor, 'lt, 'ctx, E>,
+ ) -> Canonical<'effect, Status, E>;
}
pub type DynRecoverableScope<'a, 'ctx, E> = &'a mut (dyn RecoverableScope<'ctx, E> + 'a);
-pub fn visit_recoverable<'a, 'ctx, E: Environment>(
- visitor: DynVisitor<'a, 'ctx, E>,
+pub fn visit_recoverable<'a, 'lt, 'ctx, E: Environment>(
+ visitor: DynVisitor<'a, 'lt, 'ctx, E>,
scope: DynRecoverableScope<'a, 'ctx, E>,
-) -> NativeForm<'a, VisitResult, E> {
+) -> Canonical<'a, VisitResult, E> {
if let Some(object) = visitor
.0
.cast_mut()
- .upcast_mut::<dyn Recoverable<'ctx, E> + 'a>()
+ .upcast_mut::<dyn Recoverable<'ctx, E> + 'lt>()
{
// Allow the visitor to give a hint if it wants.
object.visit(scope)
diff --git a/src/protocol/visitor/request_hint.rs b/src/protocol/visitor/request_hint.rs
index f78dd23..ea22b7a 100644
--- a/src/protocol/visitor/request_hint.rs
+++ b/src/protocol/visitor/request_hint.rs
@@ -1,7 +1,5 @@
use effectful::{
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
- SendSync,
+ effective::{Canonical, Effective}, environment::Environment, DynBind, SendSync
};
use crate::{
@@ -18,10 +16,10 @@ pub trait RequestHint<'ctx, E: Environment>: DynBind<E> {
///
/// `walker` is what the visitor (`self`) will call to give a hint using the
/// [`Hint`][crate::builtins::walker::Hint] protocol.
- fn request_hint<'this: 'e, 'walker: 'e, 'e>(
+ fn request_hint<'this: 'e, 'walker: 'e, 'lt: 'e, 'e>(
&'this mut self,
- walker: DynWalker<'walker, 'ctx, E>,
- ) -> NativeForm<'e, VisitResult, E>
+ walker: DynWalker<'walker, 'lt, 'ctx, E>,
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this + 'walker;
}
@@ -51,12 +49,12 @@ const _: () = {
/// If [`Flow::Done`] is returned then the visitor doesn't need any more information and the walker
/// should stop walking.
/// If [`Flow::Break`] is returned then there was an error and the walker should stop walking.
-pub fn request_hint<'ctx: 'visitor + 'walker, 'visitor: 'e, 'walker: 'e, 'e, E: Environment>(
- visitor: DynVisitor<'visitor, 'ctx, E>,
- walker: DynWalker<'walker, 'ctx, E>,
-) -> NativeForm<'e, VisitResult<DynWalker<'walker, 'ctx, E>>, E> {
+pub fn request_hint<'ctx: 'visitor + 'walker, 'visitor: 'e, 'lt: 'e, 'lt2: 'e, 'walker: 'e, 'e, E: Environment>(
+ visitor: DynVisitor<'visitor, 'lt, 'ctx, E>,
+ walker: DynWalker<'walker, 'lt2, 'ctx, E>,
+) -> Canonical<'e, VisitResult<DynWalker<'walker, 'lt2, 'ctx, E>>, E> {
E::value((visitor, walker))
- .update((), |_, (visitor, walker)| {
+ .update_map((), |_, (visitor, walker)| {
if let Some(object) = visitor
.0
.cast_mut()
diff --git a/src/protocol/visitor/sequence.rs b/src/protocol/visitor/sequence.rs
index 1fa221c..340678f 100644
--- a/src/protocol/visitor/sequence.rs
+++ b/src/protocol/visitor/sequence.rs
@@ -1,8 +1,5 @@
use effectful::{
- effective::Effective,
- environment::{DynBind, EnvConfig, Environment, InEnvironment, NativeForm},
- higher_ranked::Rank1,
- SendSync,
+ effective::{Canonical, Effective}, environment::{Environment, InEnvironment}, higher_ranked::Rank1, DynBind, SendSync
};
use crate::{
@@ -22,7 +19,7 @@ pub trait Sequence<'ctx, E: Environment>: DynBind<E> {
fn visit<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
scope: DynSequenceScope<'b, 'ctx, E>,
- ) -> NativeForm<'c, VisitResult, E>
+ ) -> Canonical<'c, VisitResult, E>
where
'ctx: 'a;
}
@@ -56,12 +53,12 @@ const _: () = {
};
pub trait SequenceScope<'ctx, E: Environment>: DynBind<E> {
- fn size_hint(&mut self) -> NativeForm<'_, (usize, Option<usize>), E>;
+ fn size_hint(&mut self) -> Canonical<'_, (usize, Option<usize>), E>;
- fn next<'a: 'c, 'b: 'c, 'c>(
+ fn next<'a: 'c, 'lt: 'c, 'b: 'c, 'c>(
&'a mut self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Flow, E>
+ visitor: DynVisitor<'b, 'lt, 'ctx, E>,
+ ) -> Canonical<'c, Flow, E>
where
'ctx: 'c + 'a + 'b;
}
@@ -79,14 +76,14 @@ pub struct SequenceHint {
}
#[inline(always)]
-pub fn visit_sequence<'a, 'ctx, E: Environment>(
- visitor: DynVisitor<'a, 'ctx, E>,
+pub fn visit_sequence<'a, 'lt, 'ctx, E: Environment>(
+ visitor: DynVisitor<'a, 'lt, 'ctx, E>,
scope: DynSequenceScope<'a, 'ctx, E>,
-) -> NativeForm<'a, VisitResult, E> {
+) -> Canonical<'a, VisitResult, E> {
if let Some(object) = visitor
.0
.cast_mut()
- .upcast_mut::<dyn Sequence<'ctx, E> + 'a>()
+ .upcast_mut::<dyn Sequence<'ctx, E> + 'lt>()
{
// Allow the visitor to walk the sequence scope.
object.visit(scope)
diff --git a/src/protocol/visitor/tag.rs b/src/protocol/visitor/tag.rs
index b398312..3cbe1b8 100644
--- a/src/protocol/visitor/tag.rs
+++ b/src/protocol/visitor/tag.rs
@@ -1,10 +1,7 @@
use core::any::TypeId;
use effectful::{
- effective::{Effective, EffectiveExt},
- environment::{DynBind, EnvConfig, Environment, NativeForm},
- higher_ranked::Rank1,
- tri, SendSync,
+ bound::SsBound, effective::{Canonical, Effective}, environment::Environment, higher_ranked::Rank1, tri, DynBind, SendSync
};
use crate::{
@@ -31,15 +28,15 @@ pub mod tags {
pub type TypeId = TagConst<{ Symbol::new("Type ID").to_int() }>;
}
-pub trait TagKind<E: EnvConfig>: Copy + DynBind<E> + 'static {
+pub trait TagKind<E: SsBound>: Copy + DynBind<E> + 'static {
fn symbol(&self) -> Symbol;
}
-pub trait ConstTagKind<E: EnvConfig>: TagKind<E> {
+pub trait ConstTagKind<E: SsBound>: TagKind<E> {
const NEW: Self;
}
-impl<E: EnvConfig, const SYMBOL: u64> ConstTagKind<E> for TagConst<SYMBOL> {
+impl<E: SsBound, const SYMBOL: u64> ConstTagKind<E> for TagConst<SYMBOL> {
const NEW: Self = TagConst;
}
@@ -49,7 +46,7 @@ pub struct TagConst<const SYMBOL: u64>;
#[derive(Copy, Clone, SendSync)]
pub struct TagDyn(pub Symbol);
-impl<const SYMBOL: u64, E: EnvConfig> TagKind<E> for TagConst<SYMBOL> {
+impl<const SYMBOL: u64, E: SsBound> TagKind<E> for TagConst<SYMBOL> {
fn symbol(&self) -> Symbol {
Symbol::from_int(SYMBOL)
}
@@ -59,18 +56,21 @@ impl<const SYMBOL: u64> TagConst<SYMBOL> {
pub const VALUE: Symbol = Symbol::from_int(SYMBOL);
}
-impl<E: EnvConfig> TagKind<E> for TagDyn {
+impl<E: SsBound> TagKind<E> for TagDyn {
fn symbol(&self) -> Symbol {
self.0
}
}
pub trait Tag<'ctx, K: TagKind<E>, E: Environment>: DynBind<E> {
- fn visit<'a: 'c, 'b: 'c, 'c>(
+ fn visit<'a: 'c, 'b: 'c, 'd: 'c, 'c>(
&'a mut self,
kind: K,
- walker: DynWalkerObjSafe<'b, 'ctx, E>,
- ) -> NativeForm<'c, VisitResult, E>;
+ walker: DynWalkerObjSafe<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, VisitResult, E>
+ where
+ 'ctx: 'd
+ ;
}
const _: () = {
@@ -135,28 +135,28 @@ pub struct TagError<E> {
}
impl<E> TagError<E> {
- fn new<K: TagKind<Env>, Env: EnvConfig>(tag: K, err: E) -> Self {
+ fn new<K: TagKind<Env>, Env: SsBound>(tag: K, err: E) -> Self {
Self {
symbol: tag.symbol(),
err: TagErrorKind::Walker(err),
}
}
- fn never_walked<K: TagKind<Env>, Env: EnvConfig>(tag: K) -> Self {
+ fn never_walked<K: TagKind<Env>, Env: SsBound>(tag: K) -> Self {
Self {
symbol: tag.symbol(),
err: TagErrorKind::NeverWalked,
}
}
- fn walk_never_finished<K: TagKind<Env>, Env: EnvConfig>(tag: K) -> Self {
+ fn walk_never_finished<K: TagKind<Env>, Env: SsBound>(tag: K) -> Self {
Self {
symbol: tag.symbol(),
err: TagErrorKind::WalkNeverFinished,
}
}
- fn was_walked<K: TagKind<Env>, Env: EnvConfig>(tag: K) -> Self {
+ fn was_walked<K: TagKind<Env>, Env: SsBound>(tag: K) -> Self {
Self {
symbol: tag.symbol(),
err: TagErrorKind::SkippedWasWalked,
@@ -168,21 +168,22 @@ impl<E> TagError<E> {
pub fn visit_tag<
'ctx: 'visitor,
'visitor: 'wrap,
+ 'lt: 'wrap,
'wrap,
K: TagKind<E>,
E: Environment,
W: crate::Walker<'ctx, E> + 'wrap,
>(
kind: K,
- visitor: DynVisitor<'visitor, 'ctx, E>,
+ visitor: DynVisitor<'visitor, 'lt, 'ctx, E>,
walker: W,
-) -> NativeForm<'wrap, Result<VisitResult<W>, TagError<W::Error>>, E> {
+) -> Canonical<'wrap, Result<VisitResult<W>, TagError<W::Error>>, E> {
// Wrap the walker to allow it to be passed to a dyn walker argument.
let walker = DynWalkerAdapter::new(walker);
// Give everything to the effective chain to be used as context.
E::value((kind, visitor, walker))
- .update((), |_, (kind, visitor, walker)| {
+ .update_map((), |_, (kind, visitor, walker)| {
// Try to visit the tag kind as given.
tri!(visitor.upcast_mut::<dyn Tag<'ctx, K, E>>())
.visit(*kind, walker)
diff --git a/src/protocol/visitor/value.rs b/src/protocol/visitor/value.rs
index 5ab8887..dd2def1 100644
--- a/src/protocol/visitor/value.rs
+++ b/src/protocol/visitor/value.rs
@@ -3,11 +3,7 @@
//! In some sense, this is the most basic protocol.
use effectful::{
- bound::Dynamic,
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
- higher_ranked::{for_lt, Rank1},
- SendSync,
+ bound::Dynamic, effective::{Canonical, Effective}, environment::Environment, higher_ranked::{for_lt, Rank1}, DynBind, SendSync
};
use crate::{
@@ -34,7 +30,7 @@ pub trait Value<'ctx, T: ?Sized + type_name::Static, E: Environment>: DynBind<E>
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, T>,
- ) -> NativeForm<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, T>>>, E>
+ ) -> Canonical<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, T>>>, E>
where
type_name::Lowered<'value, 'ctx, T>: Sized,
Dynamic<type_name::Lowered<'value, 'ctx, T>>: DynBind<E>,
@@ -86,13 +82,14 @@ pub struct ValueKnown<'a, T: ?Sized> {
pub fn visit_value<
'ctx: 'visitor,
'visitor: 'e,
+ 'lt: 'e,
'e,
T: type_name::WithLt<'e, 'ctx>,
E: Environment,
>(
- visitor: DynVisitor<'visitor, 'ctx, E>,
+ visitor: DynVisitor<'visitor, 'lt, 'ctx, E>,
value: T,
-) -> NativeForm<'e, VisitResult<Dynamic<T>>, E>
+) -> Canonical<'e, VisitResult<Dynamic<T>>, E>
where
Dynamic<T>: DynBind<E>,
type_name::Raised<'e, 'ctx, T>: type_name::Static,
diff --git a/src/protocol/walker/hint.rs b/src/protocol/walker/hint.rs
index dc2a37e..9b86ded 100644
--- a/src/protocol/walker/hint.rs
+++ b/src/protocol/walker/hint.rs
@@ -7,10 +7,7 @@
use core::ops::{Deref, DerefMut};
use effectful::{
- effective::Effective,
- environment::{DynBind, EnvConfig, Environment, InEnvironment, NativeForm},
- higher_ranked::{Hrt, WithLt},
- SendSync,
+ effective::{Canonical, Effective}, environment::{Environment, InEnvironment}, higher_ranked::{Hrt, WithLt}, DynBind, SendSync
};
use crate::{
@@ -38,11 +35,11 @@ pub trait Hint<'ctx, Protocol: ?Sized + HintMeta>: DynBind<Protocol::Env> {
/// Hint to the walker to use the `P` protocol.
///
/// This should only be called once per [`RequestHint`].
- fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+ fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>(
&'this mut self,
- visitor: DynVisitorWith<'visitor, 'ctx, Protocol>,
+ visitor: DynVisitorWith<'visitor, 'lt, 'ctx, Protocol>,
hint: WithLt<'hint, Protocol::Hint>,
- ) -> NativeForm<'e, VisitResult, Protocol::Env>
+ ) -> Canonical<'e, VisitResult, Protocol::Env>
where
'ctx: 'this + 'visitor + 'hint;
@@ -50,21 +47,21 @@ pub trait Hint<'ctx, Protocol: ?Sized + HintMeta>: DynBind<Protocol::Env> {
fn known<'a>(
&'a mut self,
hint: &'a WithLt<'a, Protocol::Hint>,
- ) -> NativeForm<'a, Result<WithLt<'a, Protocol::Known>, ()>, Protocol::Env>
+ ) -> Canonical<'a, Result<WithLt<'a, Protocol::Known>, ()>, Protocol::Env>
where
WithLt<'a, Protocol::Known>: DynBind<Protocol::Env>;
}
#[derive(SendSync)]
-pub struct DynVisitorWith<'temp, 'ctx, Protocol: ?Sized + HintMeta> {
- visitor: DynVisitor<'temp, 'ctx, Protocol::Env>,
+pub struct DynVisitorWith<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> {
+ visitor: DynVisitor<'temp, 'lt, 'ctx, Protocol::Env>,
_marker: Marker<Protocol>,
}
-impl<'temp, 'ctx: 'temp, Protocol: ?Sized + HintMeta> DynVisitorWith<'temp, 'ctx, Protocol> {
+impl<'temp, 'lt: 'temp, 'ctx: 'lt, Protocol: ?Sized + HintMeta> DynVisitorWith<'temp, 'lt, 'ctx, Protocol> {
pub fn new<T>(visitor: &'temp mut T) -> Self
where
- T: AnyTraitDynBind<'temp, 'ctx, Protocol::Env>,
+ T: AnyTraitDynBind<'lt, 'ctx, Protocol::Env>,
{
Self {
visitor: DynVisitor(visitor),
@@ -72,26 +69,26 @@ impl<'temp, 'ctx: 'temp, Protocol: ?Sized + HintMeta> DynVisitorWith<'temp, 'ctx
}
}
- pub fn as_known(&mut self) -> &mut type_name::Lowered<'temp, 'ctx, Protocol> {
+ pub fn as_known(&mut self) -> &mut type_name::Lowered<'lt, 'ctx, Protocol> {
self.visitor
- .upcast_mut::<type_name::Lowered<'temp, 'ctx, Protocol>>()
+ .upcast_mut::<type_name::Lowered<'lt, 'ctx, Protocol>>()
.unwrap()
}
- pub fn into_inner(self) -> DynVisitor<'temp, 'ctx, Protocol::Env> {
+ pub fn into_inner(self) -> DynVisitor<'temp, 'lt, 'ctx, Protocol::Env> {
self.visitor
}
}
-impl<'temp, 'ctx, Protocol: ?Sized + HintMeta> Deref for DynVisitorWith<'temp, 'ctx, Protocol> {
- type Target = DynVisitor<'temp, 'ctx, Protocol::Env>;
+impl<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> Deref for DynVisitorWith<'temp, 'lt, 'ctx, Protocol> {
+ type Target = DynVisitor<'temp, 'lt, 'ctx, Protocol::Env>;
fn deref(&self) -> &Self::Target {
&self.visitor
}
}
-impl<'temp, 'ctx, Protocol: ?Sized + HintMeta> DerefMut for DynVisitorWith<'temp, 'ctx, Protocol> {
+impl<'temp, 'lt, 'ctx, Protocol: ?Sized + HintMeta> DerefMut for DynVisitorWith<'temp, 'lt, 'ctx, Protocol> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.visitor
}
@@ -121,23 +118,24 @@ pub fn hint_protocol<
'walker: 'e,
'visitor: 'e,
'hint: 'e,
+ 'lt: 'e,
'e,
Protocol: ?Sized + type_name::WithLt<'static, 'static>,
E,
T,
>(
- walker: DynWalker<'walker, 'ctx, E>,
+ walker: DynWalker<'walker, 'lt, 'ctx, E>,
visitor: &'visitor mut T,
hint: WithLt<'hint, <type_name::Raised<'static, 'static, Protocol> as HintMeta>::Hint>,
-) -> NativeForm<'e, VisitResult<()>, E>
+) -> Canonical<'e, VisitResult<()>, E>
where
E: Environment,
- T: AnyTrait<'ctx> + DynBind<E>,
+ T: AnyTrait<'lt, 'ctx> + DynBind<E>,
type_name::Raised<'static, 'static, Protocol>: HintMeta<Env = E>,
{
if let Some(object) = walker
.0
- .cast_mut2()
+ .cast_mut()
.upcast_mut::<dyn Hint<'ctx, type_name::Raised<'static, 'static, Protocol>> + '_>()
{
object
diff --git a/src/transform.rs b/src/transform.rs
index 48b0f03..ed38a08 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -1,10 +1,5 @@
use effectful::{
- block_on::Spin,
- blocking::Blocking,
- bound::{DynamicShim, No, Yes},
- effective::Effective,
- environment::{Cfg, Environment, NativeForm},
- r#async::Async,
+ r#async::{Async, AsyncSpin}, block_on::Spin, blocking::{Blocking, BlockingSpin}, bound::{Dynamic, No, Yes}, effective::{Canonical, Effective, FutureShim}, environment::Environment
};
use futures::Future;
@@ -14,16 +9,17 @@ use crate::{build::Builder, build::BuilderTypes, Build, DefaultMode, Walk, Walke
#[allow(clippy::type_complexity)]
pub fn transform<
'a,
- 'ctx: 'a,
- B: Builder<'ctx, E> + 'a,
+ 'builder: 'a,
+ 'ctx: 'builder,
+ B: Builder<'builder, 'ctx, E> + 'a,
W: Walker<'ctx, E> + 'a,
E: Environment,
>(
seed: B::Seed,
walker: W,
-) -> NativeForm<'a, (Result<B::Output, B::Error>, Result<W::Output, W::Error>), E> {
+) -> Canonical<'a, (Result<B::Output, B::Error>, Result<W::Output, W::Error>), E> {
B::from_seed(seed)
- .update(walker, |walker, builder| {
+ .update_map(walker, |walker, builder| {
walker.walk(builder.as_visitor()).cast()
})
.then((), |_, (builder, walker_result)| {
@@ -71,49 +67,47 @@ where
pub trait BuildExt {
/// Build a value of this type using the default builder.
#[allow(clippy::type_complexity)]
- fn build<'ctx, W>(
+ fn build<'lt, 'ctx: 'lt, W>(
walker: W,
) -> Result<
Self,
BuildError<
- <Self::Builder as BuilderTypes<Blocking<Cfg<Spin, No, No>>>>::Error,
- <W as Walker<'ctx, Blocking<Cfg<Spin, No, No>>>>::Error,
+ <Self::Builder as BuilderTypes<BlockingSpin>>::Error,
+ <W as Walker<'ctx, BlockingSpin>>::Error,
>,
>
where
- Self: Build<'ctx, DefaultMode, Blocking<Cfg<Spin, No, No>>>,
- <Self::Builder as BuilderTypes<Blocking<Cfg<Spin, No, No>>>>::Seed: Default,
- W: Walker<'ctx, Blocking<Cfg<Spin, No, No>>>,
+ Self: Build<'lt, 'ctx, DefaultMode, BlockingSpin>,
+ <Self::Builder as BuilderTypes<BlockingSpin>>::Seed: Default,
+ W: Walker<'ctx, BlockingSpin>,
{
- match transform::<Self::Builder, _, _>(Default::default(), walker).into_value() {
+ match transform::<Self::Builder, _, _>(Default::default(), walker).wait() {
(Ok(value), _) => Ok(Self::Builder::unwrap_output(value)),
(Err(err), Ok(_)) => Err(BuildError::Builder(err)),
(Err(build_err), Err(walker_err)) => Err(BuildError::Both(build_err, walker_err)),
}
}
- fn build_async<'ctx, W>(
+ fn build_async<'lt, 'ctx: 'lt, W>(
walker: W,
) -> impl Future<
Output = Result<
Self,
BuildError<
- <Self::Builder as BuilderTypes<Async<Cfg<Spin, Yes, Yes>>>>::Error,
- <W as Walker<'ctx, Async<Cfg<Spin, Yes, Yes>>>>::Error,
+ <Self::Builder as BuilderTypes<AsyncSpin>>::Error,
+ <W as Walker<'ctx, AsyncSpin>>::Error,
>,
>,
> + Send
- + Sync
where
- Self: Build<'ctx, DefaultMode, Async<Cfg<Spin, Yes, Yes>>>,
- <Self::Builder as BuilderTypes<Async<Cfg<Spin, Yes, Yes>>>>::Seed: Default,
- W: Walker<'ctx, Async<Cfg<Spin, Yes, Yes>>>,
+ Self: Build<'lt, 'ctx, DefaultMode, AsyncSpin>,
+ <Self::Builder as BuilderTypes<AsyncSpin>>::Seed: Default,
+ W: Walker<'ctx, AsyncSpin>,
{
- let walker = DynamicShim(walker);
+ let walker = Dynamic(walker);
async {
let walker = walker;
- match transform::<Self::Builder, _, _>(Default::default(), walker.0)
- .into_future()
+ match FutureShim::new(transform::<Self::Builder, _, _>(Default::default(), walker.0)).into_inner()
.await
{
(Ok(value), _) => Ok(Self::Builder::unwrap_output(value)),
@@ -123,12 +117,12 @@ pub trait BuildExt {
}
}
- fn new_builder<'ctx>() -> Self::Builder
+ fn new_builder<'lt, 'ctx: 'lt>() -> Self::Builder
where
- Self: Build<'ctx, DefaultMode, Blocking<Cfg<Spin, No, No>>>,
- <Self::Builder as BuilderTypes<Blocking<Cfg<Spin, No, No>>>>::Seed: Default,
+ Self: Build<'lt, 'ctx, DefaultMode, BlockingSpin>,
+ <Self::Builder as BuilderTypes<BlockingSpin>>::Seed: Default,
{
- Self::Builder::from_seed(Default::default()).into_value()
+ Self::Builder::from_seed(Default::default()).wait()
}
}
@@ -137,33 +131,33 @@ impl<T> BuildExt for T {}
pub trait WalkExt {
fn as_walker<'ctx: 'a, 'a>(
&'a self,
- ) -> <&'a Self as Walk<'ctx, DefaultMode, Blocking<Cfg<Spin, No, No>>>>::Walker
+ ) -> <&'a Self as Walk<'ctx, DefaultMode, BlockingSpin>>::Walker
where
- &'a Self: Walk<'ctx, DefaultMode, Blocking<Cfg<Spin, No, No>>>,
+ &'a Self: Walk<'ctx, DefaultMode, BlockingSpin>,
{
- Walk::into_walker(self).into_value()
+ Walk::into_walker(self).wait()
}
fn as_async_walker<'ctx: 'a, 'a>(
&'a self,
- ) -> impl Future<Output = <&'a Self as Walk<'ctx, DefaultMode, Async<Cfg<Spin, Yes, Yes>>>>::Walker>
+ ) -> impl Future<Output = <&'a Self as Walk<'ctx, DefaultMode, AsyncSpin>>::Walker>
where
- &'a Self: Walk<'ctx, DefaultMode, Async<Cfg<Spin, Yes, Yes>>>,
+ &'a Self: Walk<'ctx, DefaultMode, AsyncSpin>,
{
- Walk::into_walker(self).into_future()
+ FutureShim::new(Walk::into_walker(self))
}
#[allow(clippy::result_unit_err)]
- fn walk<'ctx: 'a, 'a, B>(&'a self, builder: B) -> Result<B::Value, ()>
+ fn walk<'lt, 'ctx: 'lt + 'a, 'a, B>(&'a self, builder: B) -> Result<B::Value, ()>
where
- &'a Self: Walk<'ctx, DefaultMode, Blocking<Cfg<Spin, No, No>>>,
- B: Builder<'ctx, Blocking<Cfg<Spin, No, No>>>,
+ &'a Self: Walk<'ctx, DefaultMode, BlockingSpin>,
+ B: Builder<'lt, 'ctx, BlockingSpin>,
{
let mut builder = builder;
let _ = Walk::into_walker(self)
- .into_value()
+ .wait()
.walk(builder.as_visitor());
- match builder.build().into_value() {
+ match builder.build().wait() {
Ok(value) => Ok(B::unwrap_output(value)),
_ => todo!(),
}
diff --git a/src/walk.rs b/src/walk.rs
index b4fdd47..b2564da 100644
--- a/src/walk.rs
+++ b/src/walk.rs
@@ -3,9 +3,7 @@ pub mod walkers;
use core::fmt::Debug;
use effectful::{
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
- SendSync,
+ effective::{Canonical, Effective}, environment::Environment, DynBind, SendSync
};
use crate::{protocol::DynVisitor, Flow};
@@ -16,7 +14,7 @@ pub trait Walk<'ctx, M, E: Environment>: Sized {
type Walker: Walker<'ctx, E>;
#[must_use]
- fn into_walker<'e>(self) -> NativeForm<'e, Self::Walker, E>
+ fn into_walker<'e>(self) -> Canonical<'e, Self::Walker, E>
where
Self: 'e;
}
@@ -41,24 +39,25 @@ pub trait Walker<'ctx, E: Environment>: DynBind<E> {
/// Walk the value.
///
/// The walker should send data to the `visitor` as it walks the value.
- fn walk<'visitor: 'effect, 'effect>(
+ fn walk<'visitor: 'effect, 'lt: 'effect, 'effect>(
self,
- visitor: DynVisitor<'visitor, 'ctx, E>,
- ) -> NativeForm<'effect, Result<Self::Output, Self::Error>, E>
+ visitor: DynVisitor<'visitor, 'lt, 'ctx, E>,
+ ) -> Canonical<'effect, Result<Self::Output, Self::Error>, E>
where
Self: 'effect;
}
-pub trait WalkerObjSafe<'ctx, E: Environment>: DynBind<E> {
- fn walk<'a: 'c, 'b: 'c, 'c>(
+pub trait WalkerObjSafe<'lt, 'ctx: 'lt, E: Environment>: DynBind<E> + 'lt {
+ fn walk<'a: 'c, 'b: 'c, 'd: 'b, 'c>(
&'a mut self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Flow, E>
+ visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Flow, E>
where
+ 'ctx: 'd,
Self: 'a;
}
-pub type DynWalkerObjSafe<'a, 'ctx, E> = &'a mut (dyn WalkerObjSafe<'ctx, E> + 'a);
+pub type DynWalkerObjSafe<'a, 'lt, 'ctx, E> = &'a mut (dyn WalkerObjSafe<'lt, 'ctx, E> + 'lt);
#[derive(SendSync)]
enum DynWalkerState<'ctx, W: Walker<'ctx, E>, E: Environment> {
@@ -114,16 +113,16 @@ impl<'ctx, W: Walker<'ctx, E>, E: Environment> DynWalkerAdapter<'ctx, W, E> {
}
}
-impl<'ctx, W: Walker<'ctx, E>, E: Environment> WalkerObjSafe<'ctx, E>
+impl<'lt, 'ctx: 'lt, W: Walker<'ctx, E> + 'lt, E: Environment> WalkerObjSafe<'lt, 'ctx, E>
for DynWalkerAdapter<'ctx, W, E>
where
Self: DynBind<E>,
{
#[inline(always)]
- fn walk<'a: 'c, 'b: 'c, 'c>(
+ fn walk<'a: 'c, 'b: 'c, 'd: 'b, 'c>(
&'a mut self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Flow, E>
+ visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Flow, E>
where
Self: 'a,
{
@@ -131,7 +130,7 @@ where
core::mem::replace(&mut self.state, DynWalkerState::Walking)
{
E::value((self, visitor))
- .update(walker, |walker, (this, visitor)| {
+ .update_map(walker, |walker, (this, visitor)| {
// Walk the walker.
walker
.walk(visitor.cast())
diff --git a/src/walk/walkers/core/bool.rs b/src/walk/walkers/core/bool.rs
index af81c92..307e300 100644
--- a/src/walk/walkers/core/bool.rs
+++ b/src/walk/walkers/core/bool.rs
@@ -1,7 +1,7 @@
use effectful::{
bound::Dynamic,
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
+ effective::{Canonical, Effective},
+ environment::Environment, DynBind,
};
use crate::{any::OwnedStatic, Walk};
@@ -15,7 +15,7 @@ where
{
type Walker = ValueWalker<bool>;
- fn into_walker<'e>(self) -> NativeForm<'e, Self::Walker, E> {
+ fn into_walker<'e>(self) -> Canonical<'e, Self::Walker, E> {
E::value(ValueWalker::new(self)).cast()
}
}
@@ -27,7 +27,7 @@ where
{
type Walker = ValueWalker<bool>;
- fn into_walker<'e>(self) -> NativeForm<'e, Self::Walker, E> {
+ fn into_walker<'e>(self) -> Canonical<'e, Self::Walker, E> {
E::value(ValueWalker::new(*self)).cast()
}
}
diff --git a/src/walk/walkers/core/int.rs b/src/walk/walkers/core/int.rs
index 2416849..4eea290 100644
--- a/src/walk/walkers/core/int.rs
+++ b/src/walk/walkers/core/int.rs
@@ -1,7 +1,8 @@
use effectful::bound::Dynamic;
use effectful::effective::Effective;
-use effectful::environment::{DynBind, Environment, NativeForm};
-use effectful::SendSync;
+use effectful::environment::{Environment};
+use effectful::effective::{Canonical};
+use effectful::{DynBind, SendSync};
use crate::{
any::AnyTrait,
@@ -109,17 +110,17 @@ where
type Output = Dynamic<T>;
- fn walk<'visitor: 'effect, 'effect>(
+ fn walk<'visitor: 'effect, 'lt: 'effect, 'effect>(
self,
- visitor: DynVisitor<'visitor, 'ctx, E>,
- ) -> NativeForm<'effect, Result<Self::Output, Self::Error>, E>
+ visitor: DynVisitor<'visitor, 'lt, 'ctx, E>,
+ ) -> Canonical<'effect, Result<Self::Output, Self::Error>, E>
where
Self: 'effect,
{
let value = self.value;
E::value((self, visitor))
- .update((), |_, (this, visitor)| {
+ .update_map((), |_, (this, visitor)| {
request_hint::<E>(visitor.cast(), DynWalker(this))
.map((), |_, x| VisitResult::unit_skipped(x))
.cast()
@@ -273,7 +274,7 @@ impl<T> Integer for T where
{
}
-impl<'ctx, T, E> AnyTrait<'ctx> for IntegerWalker<T, E>
+impl<'lt, 'ctx: 'lt, T, E> AnyTrait<'lt, 'ctx> for IntegerWalker<T, E>
where
T: Integer,
E: Environment,
@@ -329,11 +330,11 @@ macro_rules! impl_hints {
Dynamic<OwnedStatic<$type>>: DynBind<E>,
for<'a> Dynamic<&'a OwnedStatic<$type>>: DynBind<E>
{
- fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+ fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>(
&'this mut self,
- visitor: DynVisitorWith<'visitor, 'ctx, type_name::Raised<'static, 'ctx, dyn Value<'ctx, OwnedStatic<$type>, E>>>,
+ visitor: DynVisitorWith<'visitor, 'lt, 'ctx, type_name::Raised<'static, 'ctx, dyn Value<'ctx, OwnedStatic<$type>, E>>>,
_hint: (),
- ) -> NativeForm<'e, crate::protocol::visitor::VisitResult, E>
+ ) -> Canonical<'e, crate::protocol::visitor::VisitResult, E>
where
'ctx: 'this + 'visitor + 'hint + 'e,
{
@@ -349,7 +350,7 @@ macro_rules! impl_hints {
fn known<'a>(
&'a mut self,
_hint: &'a (),
- ) -> NativeForm<'a, Result<ValueKnown<'a, OwnedStatic<$type>>, ()>, E>
+ ) -> Canonical<'a, Result<ValueKnown<'a, OwnedStatic<$type>>, ()>, E>
where
ValueKnown<'a, OwnedStatic<$type>>: DynBind<E>
{
diff --git a/src/walk/walkers/core/key_value.rs b/src/walk/walkers/core/key_value.rs
index 28b1e52..0ed7a28 100644
--- a/src/walk/walkers/core/key_value.rs
+++ b/src/walk/walkers/core/key_value.rs
@@ -1,6 +1,6 @@
use effectful::{
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Canonical, Effective},
+ environment::Environment,
SendSync,
};
@@ -53,10 +53,10 @@ where
type Output = ();
#[inline(always)]
- fn walk<'b: 'c, 'c>(
+ fn walk<'b: 'c, 'd: 'c, 'c>(
self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E> {
+ visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Result<Self::Output, Self::Error>, E> {
let Self {
key_walker,
value_walker,
@@ -64,7 +64,7 @@ where
} = self;
E::value(visitor)
- .update(key_walker, |key_walker, visitor| {
+ .update_map(key_walker, |key_walker, visitor| {
visit_tag::<tags::Key, E, _>(TagConst, visitor.cast(), key_walker)
.map((), |_, result| match result {
Ok(visit) => visit.unit_skipped(),
diff --git a/src/walk/walkers/core/noop.rs b/src/walk/walkers/core/noop.rs
index 5782fbf..7cb19de 100644
--- a/src/walk/walkers/core/noop.rs
+++ b/src/walk/walkers/core/noop.rs
@@ -1,6 +1,6 @@
use effectful::{
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Canonical, Effective},
+ environment::Environment,
SendSync,
};
@@ -24,10 +24,10 @@ impl<'ctx, E: Environment> crate::Walker<'ctx, E> for NoopWalker {
type Output = ();
- fn walk<'b: 'c, 'c>(
+ fn walk<'b: 'c, 'd: 'c, 'c>(
self,
- _visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E> {
+ _visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Result<Self::Output, Self::Error>, E> {
E::value(Ok(())).cast()
}
}
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs
index 283db72..d66d112 100644
--- a/src/walk/walkers/core/struct.rs
+++ b/src/walk/walkers/core/struct.rs
@@ -2,10 +2,11 @@ use core::any::TypeId;
use effectful::{
bound::Dynamic,
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
higher_ranked::{for_lt, Rank1, WithLt},
SendSync,
+ DynBind,
};
use crate::{
@@ -62,11 +63,11 @@ pub trait StructTypeInfo<'ctx, M, E: Environment>: 'static {
type T: DynBind<E>;
/// Walk the given field.
- fn walk_field<'a>(
+ fn walk_field<'a, 'lt>(
index: usize,
value: &'ctx Self::T,
- visitor: DynVisitor<'a, 'ctx, E>,
- ) -> NativeForm<'a, Result<Flow, Self::FieldError>, E>;
+ visitor: DynVisitor<'a, 'lt, 'ctx, E>,
+ ) -> Canonical<'a, Result<Flow, Self::FieldError>, E>;
}
#[derive(Debug, PartialEq, Clone, Copy, SendSync)]
@@ -118,26 +119,26 @@ where
}
}
-impl<'ctx, I, S, E, M> crate::Walker<'ctx, E> for StructWalker<'ctx, I, S, M, E>
+impl<'lt, 'ctx, I, S, E, M> crate::Walker<'ctx, E> for StructWalker<'ctx, I, S, M, E>
where
E: Environment,
I: StructTypeInfo<'ctx, M, E, S = S>,
- Self: AnyTrait<'ctx> + RecoverableScope<'ctx, E>,
+ Self: AnyTrait<'lt, 'ctx> + RecoverableScope<'ctx, E>,
{
type Error = StructWalkError<I::FieldError>;
type Output = ();
#[inline(always)]
- fn walk<'b: 'c, 'c>(
+ fn walk<'b: 'c, 'd: 'c, 'c>(
self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E>
+ visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Result<Self::Output, Self::Error>, E>
where
Self: 'c,
{
E::value((self, visitor))
- .update((), |_, (this, visitor)| {
- RecoverableScope::<'ctx, E>::new_walk::<'_, '_, '_>(this, visitor.cast()).cast()
+ .update_map((), |_, (this, visitor)| {
+ RecoverableScope::<'ctx, E>::new_walk::<'_, '_, '_, '_>(this, visitor.cast()).cast()
})
.map((), |_, ((this, _), _)| match this.error {
Some(err) => Err(StructWalkError { kind: err }),
@@ -164,7 +165,7 @@ where
pub enum StaticType {}
-impl<'ctx, I, M, E> AnyTrait<'ctx> for StructWalker<'ctx, I, StaticType, M, E>
+impl<'lt, 'ctx: 'lt, I, M: 'lt, E> AnyTrait<'lt, 'ctx> for StructWalker<'ctx, I, StaticType, M, E>
where
E: Environment,
I: StructTypeInfo<'ctx, M, E, S = StaticType>,
@@ -192,23 +193,24 @@ where
// ] where
// }
-impl<'ctx, I, S, M, E> Hint<'ctx, type_name::Raised<'static, 'ctx, dyn Recoverable<'ctx, E>>>
+impl<'lt2, 'ctx, I, S, M, E> Hint<'ctx, type_name::Raised<'static, 'ctx, dyn Recoverable<'ctx, E>>>
for StructWalker<'ctx, I, S, M, E>
where
E: Environment,
I: StructTypeInfo<'ctx, M, E, S = S>,
- Self: AnyTrait<'ctx> + RecoverableScope<'ctx, E>,
+ Self: AnyTrait<'lt2, 'ctx> + RecoverableScope<'ctx, E>,
{
#[inline(always)]
- fn hint<'this, 'visitor, 'hint, 'e>(
+ fn hint<'this, 'visitor, 'lt: 'e, 'hint, 'e>(
&'this mut self,
_visitor: DynVisitorWith<
'visitor,
+ 'lt,
'ctx,
type_name::Raised<'static, 'ctx, dyn Recoverable<'ctx, E>>,
>,
_hint: (),
- ) -> NativeForm<'e, VisitResult, E>
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this + 'visitor + 'hint + 'e,
{
@@ -225,7 +227,7 @@ where
fn known<'a>(
&'a mut self,
hint: &'a WithLt<'a, Rank1<()>>,
- ) -> NativeForm<'a, Result<WithLt<'a, Rank1<()>>, ()>, E>
+ ) -> Canonical<'a, Result<WithLt<'a, Rank1<()>>, ()>, E>
where
WithLt<'a, Rank1<()>>: DynBind<E>,
{
@@ -249,7 +251,7 @@ where
// dyn Tag<'ctx, tags::FieldNames, E> + 'c,
// >,
// _hint: TagHint<tags::FieldNames>,
-// ) -> NativeForm<'e, VisitResult, E>
+// ) -> Canonical<'e, VisitResult, E>
// where
// 'ctx: 'this + 'visitor + 'hint + 'e,
// {
@@ -275,7 +277,7 @@ where
// fn known<'a>(
// &'a mut self,
// hint: &'a WithLt<'a, Rank1<()>>,
-// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// ) -> Canonical<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
// where
// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
// {
@@ -298,7 +300,7 @@ where
// &'this mut self,
// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, tags::TypeName, E> + 'c>,
// _hint: TagHint<tags::TypeName>,
-// ) -> NativeForm<'e, VisitResult, E>
+// ) -> Canonical<'e, VisitResult, E>
// where
// 'ctx: 'this + 'visitor + 'hint + 'e,
// {
@@ -324,7 +326,7 @@ where
// fn known<'a>(
// &'a mut self,
// hint: &'a WithLt<'a, Rank1<()>>,
-// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// ) -> Canonical<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
// where
// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
// {
@@ -347,7 +349,7 @@ where
// &'this mut self,
// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, tags::Map, E> + 'c>,
// _hint: TagHint<tags::Map>,
-// ) -> NativeForm<'e, VisitResult, E>
+// ) -> Canonical<'e, VisitResult, E>
// where
// 'ctx: 'this + 'visitor + 'hint + 'e,
// {
@@ -369,7 +371,7 @@ where
// fn known<'a>(
// &'a mut self,
// hint: &'a WithLt<'a, Rank1<()>>,
-// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// ) -> Canonical<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
// where
// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
// {
@@ -392,7 +394,7 @@ where
// &'this mut self,
// visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, tags::Struct, E> + 'c>,
// _hint: TagHint<tags::Struct>,
-// ) -> NativeForm<'e, VisitResult, E>
+// ) -> Canonical<'e, VisitResult, E>
// where
// 'ctx: 'this + 'visitor + 'hint + 'e,
// {
@@ -416,7 +418,7 @@ where
// fn known<'a>(
// &'a mut self,
// hint: &'a WithLt<'a, Rank1<()>>,
-// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// ) -> Canonical<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
// where
// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
// {
@@ -440,7 +442,7 @@ where
// &'this mut self,
// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, tags::TypeId, E> + 'c>,
// _hint: TagHint<tags::TypeId>,
-// ) -> NativeForm<'e, VisitResult, E>
+// ) -> Canonical<'e, VisitResult, E>
// where
// 'ctx: 'this + 'visitor + 'hint + 'e,
// {
@@ -466,7 +468,7 @@ where
// fn known<'a>(
// &'a mut self,
// hint: &'a WithLt<'a, Rank1<()>>,
-// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// ) -> Canonical<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
// where
// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
// {
@@ -489,7 +491,7 @@ where
// &'this mut self,
// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, TagDyn, E> + 'c>,
// _hint: TagHint<TagDyn>,
-// ) -> NativeForm<'e, VisitResult, E>
+// ) -> Canonical<'e, VisitResult, E>
// where
// 'ctx: 'this + 'visitor + 'hint + 'e,
// {
@@ -533,7 +535,7 @@ where
// fn known<'a>(
// &'a mut self,
// hint: &'a WithLt<'a, Rank1<TagHint<TagDyn>>>,
-// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// ) -> Canonical<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
// where
// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
// {
@@ -563,7 +565,7 @@ where
// &'this mut self,
// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Value<'ctx, BorrowedStatic<'ctx, I::T>, E> + 'x>,
// _hint: (),
-// ) -> NativeForm<'e, VisitResult, E>
+// ) -> Canonical<'e, VisitResult, E>
// where
// 'ctx: 'this + 'visitor + 'hint + 'e,
// {
@@ -581,7 +583,7 @@ where
// fn known<'a>(
// &'a mut self,
// hint: &'a WithLt<'a, Rank1<()>>,
-// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<ValueKnown<'a, BorrowedStatic<'ctx, I::T>>>>, ()>, Protocol::Env>
+// ) -> Canonical<'a, Result<WithLt<'a, Rank1<ValueKnown<'a, BorrowedStatic<'ctx, I::T>>>>, ()>, Protocol::Env>
// where
// WithLt<'a, Rank1<ValueKnown<'a, BorrowedStatic<'ctx, I::T>>>>: DynBind<Protocol::Env>
// {
@@ -598,19 +600,21 @@ where
{
#[inline(always)]
- fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+ fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>(
&'this mut self,
visitor: DynVisitorWith<
'visitor,
+ 'lt,
'ctx,
type_name::Raised<'static, 'ctx, dyn Sequence<'ctx, E>>,
>,
_hint: SequenceHint,
- ) -> NativeForm<'e, VisitResult, E>
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this + 'visitor + 'hint + 'e,
{
- E::with((self, visitor), |(this, visitor)| {
+ E::value((self, visitor))
+ .update_map((), |_, (this, visitor)| {
visitor
.as_known()
.visit(*this)
@@ -631,7 +635,7 @@ where
fn known<'a>(
&'a mut self,
hint: &'a WithLt<'a, Rank1<SequenceHint>>,
- ) -> NativeForm<'a, Result<WithLt<'a, Rank1<SequenceKnown>>, ()>, E>
+ ) -> Canonical<'a, Result<WithLt<'a, Rank1<SequenceKnown>>, ()>, E>
where
WithLt<'a, Rank1<SequenceKnown>>: DynBind<E>,
{
@@ -651,17 +655,17 @@ where
I: StructTypeInfo<'ctx, M, E, S = S>,
{
#[inline(always)]
- fn size_hint(&mut self) -> NativeForm<'_, (usize, Option<usize>), E> {
+ fn size_hint(&mut self) -> Canonical<'_, (usize, Option<usize>), E> {
let len = I::FIELDS.len();
E::value((len, Some(len))).cast()
}
#[inline(always)]
- fn next<'a: 'c, 'b: 'c, 'c>(
+ fn next<'a: 'c, 'd: 'c, 'b: 'c, 'c>(
&'a mut self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Flow, E> {
+ visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Flow, E> {
if self.index >= I::FIELDS.len() {
return E::value(Flow::Done).cast();
}
@@ -706,10 +710,10 @@ where
Dynamic<OwnedStatic<TypeId>>: DynBind<E>,
{
#[inline(always)]
- fn new_walk<'a: 'c, 'b: 'c, 'c>(
+ fn new_walk<'a: 'c, 'b: 'c, 'd: 'c, 'c>(
&'a mut self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Status, E> {
+ visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Status, E> {
// Reset the errors to default state.
self.error = None;
@@ -717,7 +721,7 @@ where
self.index = 0;
E::value((self, visitor))
- .update((), |_, (this, visitor)| {
+ .update_map((), |_, (this, visitor)| {
request_hint::<E>(visitor.cast(), DynWalker(*this))
.map((), |_, x| VisitResult::unit_skipped(x))
.cast()
diff --git a/src/walk/walkers/core/tag.rs b/src/walk/walkers/core/tag.rs
index 9827cfb..4c691b3 100644
--- a/src/walk/walkers/core/tag.rs
+++ b/src/walk/walkers/core/tag.rs
@@ -2,8 +2,8 @@ use core::marker::PhantomData;
use effectful::{
bound::IsSync,
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Canonical, Effective},
+ environment::Environment,
SendSync,
};
@@ -45,10 +45,10 @@ where
type Output = ();
#[inline(always)]
- fn walk<'b: 'c, 'c>(
+ fn walk<'b: 'c, 'd: 'c, 'c>(
self,
- _visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E> {
+ _visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Result<Self::Output, Self::Error>, E> {
todo!()
// E::wrap(async move {
// match visit_request_hint::<E>(visitor.cast(), DynWalker(&mut self)).await {
@@ -72,7 +72,7 @@ where
}
}
-impl<'ctx, T, W> AnyTrait<'ctx> for StaticSliceWalker<T, W> {}
+impl<'lt, 'ctx: 'lt, T, W: 'lt> AnyTrait<'lt, 'ctx> for StaticSliceWalker<T, W> {}
// any_trait! {
// impl['a, 'ctx, T, W][E] StaticSliceWalker<T, W> = [
@@ -87,10 +87,10 @@ where
&'static T: Into<W>,
{
#[inline(always)]
- fn next<'a: 'c, 'b: 'c, 'c>(
+ fn next<'a: 'c, 'd: 'c, 'b: 'c, 'c>(
&'a mut self,
- _visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Flow, E> {
+ _visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Flow, E> {
if let Some(_name) = self.names.get(self.current) {
self.current += 1;
todo!()
@@ -106,7 +106,7 @@ where
}
#[inline(always)]
- fn size_hint(&mut self) -> NativeForm<'_, (usize, Option<usize>), E> {
+ fn size_hint(&mut self) -> Canonical<'_, (usize, Option<usize>), E> {
E::value((self.names.len(), Some(self.names.len()))).cast()
}
}
diff --git a/src/walk/walkers/core/value.rs b/src/walk/walkers/core/value.rs
index 69fb912..69aa04c 100644
--- a/src/walk/walkers/core/value.rs
+++ b/src/walk/walkers/core/value.rs
@@ -1,7 +1,8 @@
use effectful::{
bound::Dynamic,
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
+ DynBind,
SendSync,
};
@@ -53,10 +54,10 @@ where
type Output = ();
#[inline(always)]
- fn walk<'b: 'c, 'c>(
+ fn walk<'b: 'c, 'd: 'c, 'c>(
self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E> {
+ visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Result<Self::Output, Self::Error>, E> {
// Attempt to visit using the value protocol.
visit_value::<OwnedStatic<T>, E>(visitor, OwnedStatic(self.0 .0))
.map((), |_, _| Ok(()))
@@ -89,13 +90,13 @@ where
type Output = Dynamic<&'ctx T>;
#[inline(always)]
- fn walk<'b: 'c, 'c>(
+ fn walk<'b: 'c, 'd: 'c, 'c>(
self,
- visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E> {
+ visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Result<Self::Output, Self::Error>, E> {
// Attempt to visit using the value protocol.
E::value((self, visitor))
- .update((), |_, (this, visitor)| {
+ .update_map((), |_, (this, visitor)| {
visit_value::<_, E>(visitor.cast(), BorrowedStatic(this.0 .0))
.map((), |_, x| VisitResult::unit_skipped(x))
.cast()
diff --git a/src/walk/walkers/serde/deserializer.rs b/src/walk/walkers/serde/deserializer.rs
index 4537e07..a37b4fb 100644
--- a/src/walk/walkers/serde/deserializer.rs
+++ b/src/walk/walkers/serde/deserializer.rs
@@ -1,10 +1,11 @@
use crate::walk::walkers::core::noop::NoopWalker;
use effectful::{
- bound::{Dynamic, No},
- effective::Effective,
- environment::{DynBind, EnvConfig, Environment, NativeForm},
+ bound::{Dynamic, No, SsBound},
+ effective::{Effective, Canonical},
+ environment::{Environment},
higher_ranked::{Rank1, WithLt},
SendSync,
+ DynBind,
};
use serde::{
de::{DeserializeSeed, MapAccess},
@@ -101,21 +102,21 @@ where
impl<'ctx, T, E: Environment> Walker<'ctx, E> for DeserializerWalker<'ctx, T, E>
where
T: Deserializer<'ctx>,
- E: EnvConfig<NeedSend = No, NeedSync = No>,
+ E: SsBound<NeedSend = No, NeedSync = No>,
{
type Error = DeserializerWalkerError<'ctx, T>;
type Output = ();
- fn walk<'visitor: 'effect, 'effect>(
+ fn walk<'visitor: 'effect, 'lt: 'effect, 'effect>(
self,
- visitor: DynVisitor<'visitor, 'ctx, E>,
- ) -> NativeForm<'effect, Result<Self::Output, Self::Error>, E>
+ visitor: DynVisitor<'visitor, 'lt, 'ctx, E>,
+ ) -> Canonical<'effect, Result<Self::Output, Self::Error>, E>
where
Self: 'effect,
{
E::value((self, visitor))
- .update((), |_, (this, visitor)| {
+ .update_map((), |_, (this, visitor)| {
// Serde deserializers usually prefer that a hint method is called rather than _any.
// As such we need to ask the visitor for a hint first.
request_hint::<E>(visitor.cast(), DynWalker(this))
@@ -139,7 +140,7 @@ where
}
}
-impl<'ctx, T, E> AnyTrait<'ctx> for DeserializerWalker<'ctx, T, E>
+impl<'lt, 'ctx: 'lt, T: 'lt, E> AnyTrait<'lt, 'ctx> for DeserializerWalker<'ctx, T, E>
where
T: Deserializer<'ctx>,
E: Environment<NeedSend = No, NeedSync = No>,
@@ -169,7 +170,7 @@ where
impl<'ctx, T, E: Environment> DeserializerWalker<'ctx, T, E>
where
T: Deserializer<'ctx>,
- E: EnvConfig<NeedSend = No, NeedSync = No>,
+ E: SsBound<NeedSend = No, NeedSync = No>,
{
#[allow(clippy::type_complexity)]
fn call_deserialize<'this: 'e, 'e, Cap>(
@@ -179,10 +180,10 @@ where
Cap,
T,
) -> Result<
- NativeForm<'e, (Option<VisitorError<'ctx, T>>, VisitResult), E, (&'ctx (), Cap)>,
+ Canonical<'e, (Option<VisitorError<'ctx, T>>, VisitResult), E, (&'ctx (), Cap)>,
T::Error,
>,
- ) -> NativeForm<'e, VisitResult, E>
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this,
Cap: DynBind<E> + 'e,
@@ -230,18 +231,18 @@ macro_rules! impl_hints {
$(impl<$ctx, $T, $E: Environment> Hint<$ctx, type_name::Raised<'static, $ctx, $proto>> for DeserializerWalker<$ctx, $T, $E>
where
$T: Deserializer<$ctx>,
- $E: EnvConfig<NeedSend = No, NeedSync = No>
+ $E: SsBound<NeedSend = No, NeedSync = No>
{
- fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+ fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>(
&'this mut self,
- visitor: DynVisitorWith<'visitor, $ctx, type_name::Raised<'static, $ctx, $proto>>,
+ visitor: DynVisitorWith<'visitor, 'lt, $ctx, type_name::Raised<'static, $ctx, $proto>>,
_hint: WithLt<'hint, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Hint>,
- ) -> NativeForm<'e, VisitResult, $E>
+ ) -> Canonical<'e, VisitResult, $E>
where
$ctx: 'this + 'visitor + 'hint + 'e,
{
$E::value((self, visitor))
- .update((), |_, (this, visitor)| {
+ .update_map((), |_, (this, visitor)| {
this.call_deserialize(visitor, move |visitor, deserializer| {
let x = deserializer.$method(Visitor::<$T, $E>::new(visitor.cast(), stringify!($type)));
x.map(|x| x.cast())
@@ -255,7 +256,7 @@ macro_rules! impl_hints {
fn known<'a>(
&'a mut self,
_hint: &'a WithLt<'a, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Hint>,
- ) -> NativeForm<'a, Result<WithLt<'a, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Known>, ()>, $E>
+ ) -> Canonical<'a, Result<WithLt<'a, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Known>, ()>, $E>
where
WithLt<'a, <type_name::Raised<'static, $ctx, $proto> as HintMeta>::Known>: DynBind<$E>
{
@@ -295,17 +296,18 @@ impl<'ctx, T, E: Environment>
for DeserializerWalker<'ctx, T, E>
where
T: Deserializer<'ctx>,
- E: EnvConfig<NeedSend = No, NeedSync = No>,
+ E: SsBound<NeedSend = No, NeedSync = No>,
{
- fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+ fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>(
&'this mut self,
_visitor: DynVisitorWith<
'visitor,
+ 'lt,
'ctx,
type_name::Raised<'static, 'ctx, dyn Tag<'ctx, tags::Map, E>>,
>,
_hint: TagHint<tags::Map>,
- ) -> NativeForm<'e, VisitResult, E>
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this + 'visitor + 'hint + 'e,
{
@@ -318,7 +320,7 @@ where
fn known<'a>(
&'a mut self,
_hint: &'a WithLt<'a, Rank1<TagHint<tags::Map>>>,
- ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, E>
+ ) -> Canonical<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, E>
where
WithLt<'a, Rank1<TagKnown>>: DynBind<E>,
{
@@ -351,20 +353,20 @@ where
}
#[derive(SendSync)]
-struct Visitor<'temp, 'ctx, T, E: Environment>
+struct Visitor<'temp, 'lt, 'ctx, T, E: Environment>
where
T: Deserializer<'ctx>,
{
wanted: &'static str,
- visitor: DynVisitor<'temp, 'ctx, E>,
+ visitor: DynVisitor<'temp, 'lt, 'ctx, E>,
_marker: Marker<(T, E)>,
}
-impl<'temp, 'ctx, T, E: Environment> Visitor<'temp, 'ctx, T, E>
+impl<'temp, 'lt, 'ctx, T, E: Environment> Visitor<'temp, 'lt, 'ctx, T, E>
where
T: Deserializer<'ctx>,
{
- pub fn new(visitor: DynVisitor<'temp, 'ctx, E>, wanted: &'static str) -> Self {
+ pub fn new(visitor: DynVisitor<'temp, 'lt, 'ctx, E>, wanted: &'static str) -> Self {
Self {
wanted,
visitor,
@@ -399,12 +401,12 @@ macro_rules! impl_visits {
};
}
-impl<'temp, 'ctx, T: Deserializer<'ctx> + 'temp, E: Environment> serde::de::Visitor<'ctx>
- for Visitor<'temp, 'ctx, T, E>
+impl<'temp, 'lt, 'ctx, T: Deserializer<'ctx> + 'temp, E: Environment> serde::de::Visitor<'ctx>
+ for Visitor<'temp, 'lt, 'ctx, T, E>
where
- E: EnvConfig<NeedSend = No, NeedSync = No>,
+ E: SsBound<NeedSend = No, NeedSync = No>,
{
- type Value = NativeForm<'temp, (Option<VisitorError<'ctx, T>>, VisitResult), E>;
+ type Value = Canonical<'temp, (Option<VisitorError<'ctx, T>>, VisitResult), E>;
fn expecting(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
formatter.write_str(self.wanted)
@@ -444,9 +446,9 @@ where
where
A: MapAccess<'ctx>,
{
- E::value((self, MapScope { map: Dynamic(map) })).update((), |_, (this, scope)| {
+ E::value((self, MapScope { map: Dynamic(map) })).update_map((), |_, (this, scope)| {
// Need to notify the visitor we are doing a map instead of just a sequence.
- visit_tag::<tags::Map, E, _>(TagConst, this.visitor.cast(), NoopWalker::new());
+ let x = visit_tag::<tags::Map, E, _>(TagConst, this.visitor.cast(), NoopWalker::new()).wait();
visit_sequence(this.visitor.cast(), scope).cast()
});
@@ -462,17 +464,17 @@ struct MapScope<A> {
impl<'ctx, A, E: Environment> SequenceScope<'ctx, E> for MapScope<A>
where
- E: EnvConfig<NeedSend = No, NeedSync = No>,
+ E: SsBound<NeedSend = No, NeedSync = No>,
A: MapAccess<'ctx>,
{
- fn size_hint(&mut self) -> NativeForm<'_, (usize, Option<usize>), E> {
+ fn size_hint(&mut self) -> Canonical<'_, (usize, Option<usize>), E> {
E::value((0, self.map.0.size_hint())).cast()
}
- fn next<'a: 'c, 'b: 'c, 'c>(
+ fn next<'a: 'c, 'd: 'c, 'b: 'c, 'c>(
&'a mut self,
- mut visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Flow, E>
+ mut visitor: DynVisitor<'b, 'd, 'ctx, E>,
+ ) -> Canonical<'c, Flow, E>
where
'ctx: 'c + 'a + 'b,
{
@@ -502,13 +504,13 @@ where
}
}
-struct KeyDeserialize<'a, 'ctx, E: Environment> {
- visitor: DynVisitor<'a, 'ctx, E>,
+struct KeyDeserialize<'a, 'lt, 'ctx, E: Environment> {
+ visitor: DynVisitor<'a, 'lt, 'ctx, E>,
}
-impl<'a, 'ctx: 'a, E: Environment> DeserializeSeed<'ctx> for KeyDeserialize<'a, 'ctx, E>
+impl<'a, 'lt, 'ctx: 'a, E: Environment> DeserializeSeed<'ctx> for KeyDeserialize<'a, 'lt, 'ctx, E>
where
- E: EnvConfig<NeedSend = No, NeedSync = No>,
+ E: SsBound<NeedSend = No, NeedSync = No>,
{
type Value = ();
@@ -536,13 +538,13 @@ where
}
}
-struct ValueDeserialize<'a, 'ctx, E: Environment> {
- visitor: DynVisitor<'a, 'ctx, E>,
+struct ValueDeserialize<'a, 'lt, 'ctx, E: Environment> {
+ visitor: DynVisitor<'a, 'lt, 'ctx, E>,
}
-impl<'a, 'ctx, E: Environment> DeserializeSeed<'ctx> for ValueDeserialize<'a, 'ctx, E>
+impl<'a, 'lt, 'ctx, E: Environment> DeserializeSeed<'ctx> for ValueDeserialize<'a, 'lt, 'ctx, E>
where
- E: EnvConfig<NeedSend = No, NeedSync = No>,
+ E: SsBound<NeedSend = No, NeedSync = No>,
{
type Value = ();
diff --git a/tests/builder_enum.rs b/tests/builder_enum.rs
index d241085..7f0060c 100644
--- a/tests/builder_enum.rs
+++ b/tests/builder_enum.rs
@@ -16,12 +16,11 @@ use crate::common::{
tag::TagVisitorExt as _,
value::ValueVisitorExt as _,
},
- Blocking,
};
use effectful::{
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
SendSync,
};
diff --git a/tests/builder_struct.rs b/tests/builder_struct.rs
index f1da081..52e9b09 100644
--- a/tests/builder_struct.rs
+++ b/tests/builder_struct.rs
@@ -1,4 +1,5 @@
use effectful::SendSync;
+use effectful::blocking::BlockingSpin;
use macro_rules_attribute::derive;
use treaty::{
any::{OwnedStatic, TempBorrowedStatic},
@@ -14,7 +15,6 @@ use treaty::{
use crate::common::{
protocol::{sequence::MockSequenceScope, value::ValueVisitorExt as _},
walker::MockWalker,
- Blocking,
};
mod common;
@@ -30,7 +30,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_field_values() {
let mut scope;
{
// A tuple-like struct is just a sequence.
- scope = MockSequenceScope::<Blocking>::new();
+ scope = MockSequenceScope::<BlockingSpin>::new();
// First field.
scope.expect_next().once().returning(|mut visitor| {
@@ -73,13 +73,13 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() {
let mut scope;
{
// A map is a sequence of keyed values.
- scope = MockSequenceScope::<Blocking>::new();
+ scope = MockSequenceScope::<BlockingSpin>::new();
// Here we do the b field first to show a map-like doesn't care about order.
scope.expect_next().once().returning(|mut visitor| {
let mut walker;
{
- walker = MockWalker::<(), (), Blocking>::new();
+ walker = MockWalker::<(), (), BlockingSpin>::new();
// We need to give the b field name in the key tag.
walker.expect_walk().once().returning(|mut visitor| {
@@ -91,7 +91,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() {
// Tag the value with a key as the field name.
assert_eq!(
- visit_tag::<tags::Key, Blocking, _>(TagConst, visitor.cast(), walker).into_value(),
+ visit_tag::<tags::Key, BlockingSpin, _>(TagConst, visitor.cast(), walker).into_value(),
Ok(VisitResult::Control(Flow::Continue)),
);
@@ -106,7 +106,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() {
scope.expect_next().once().returning(|mut visitor| {
let mut walker;
{
- walker = MockWalker::<(), (), Blocking>::new();
+ walker = MockWalker::<(), (), BlockingSpin>::new();
// Here we do field a.
walker.expect_walk().once().returning(|mut visitor| {
@@ -118,7 +118,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() {
// Tag the value with a key.
assert_eq!(
- visit_tag::<tags::Key, Blocking, _>(TagConst, visitor.cast(), walker).into_value(),
+ visit_tag::<tags::Key, BlockingSpin, _>(TagConst, visitor.cast(), walker).into_value(),
Ok(VisitResult::Control(Flow::Continue)),
);
@@ -138,7 +138,7 @@ fn a_struct_builder_can_build_from_a_sequence_of_keyed_values() {
// We need to provide the map tag to the struct before getting into the sequence.
// This tag notifies the struct builder to expect the sequence as a map.
assert_eq!(
- visit_tag::<tags::Map, Blocking, _>(TagConst, builder.as_visitor(), NoopWalker::new())
+ visit_tag::<tags::Map, BlockingSpin, _>(TagConst, builder.as_visitor(), NoopWalker::new())
.into_value(),
Ok(VisitResult::Control(Flow::Continue))
);
diff --git a/tests/builder_value.rs b/tests/builder_value.rs
index b00c24a..47796ba 100644
--- a/tests/builder_value.rs
+++ b/tests/builder_value.rs
@@ -1,5 +1,6 @@
mod common;
+use effectful::blocking::BlockingSpin;
use common::walker::MockWalker;
use treaty::{
any::{type_name, BorrowedStatic, OwnedStatic, TempBorrowedStatic},
@@ -13,7 +14,6 @@ use treaty::{
use crate::common::{
protocol::{hint::MockHintWalker, value::ValueVisitorExt as _},
- Blocking,
};
#[test]
@@ -23,7 +23,7 @@ fn value_builder_gives_value_protocol_as_hint() {
// Expect the value builder to hint the value protocol with a owned i32.
let mut walker = MockHintWalker::<
- type_name::Raised<'_, '_, dyn Value<'_, OwnedStatic<i32>, Blocking>>,
+ type_name::Raised<'_, '_, dyn Value<'_, OwnedStatic<i32>, BlockingSpin>>,
>::new();
walker.expect_hint().once().returning(|mut visitor, ()| {
// Fulfill the hint by visiting with a i32 value.
@@ -38,7 +38,7 @@ fn value_builder_gives_value_protocol_as_hint() {
// Request a hint from the i32 builder for what protocol to use.
assert_eq!(
- request_hint::<Blocking>(builder.as_visitor(), DynWalker(&mut walker)).into_value(),
+ request_hint::<BlockingSpin>(builder.as_visitor(), DynWalker(&mut walker)).into_value(),
Flow::Done.into()
);
@@ -50,7 +50,7 @@ fn value_builder_gives_value_protocol_as_hint() {
fn value_builder_can_use_an_owned_value_or_a_borrowed_value() {
assert_eq!(
i32::build({
- let mut walker = MockWalker::<(), (), Blocking>::new();
+ let mut walker = MockWalker::<(), (), BlockingSpin>::new();
walker.expect_walk().once().returning(|mut visitor| {
visitor.visit_value_and_done(OwnedStatic(1));
Ok(())
@@ -63,7 +63,7 @@ fn value_builder_can_use_an_owned_value_or_a_borrowed_value() {
assert_eq!(
i32::build({
- let mut walker = MockWalker::<(), (), Blocking>::new();
+ let mut walker = MockWalker::<(), (), BlockingSpin>::new();
walker.expect_walk().once().returning(|mut visitor| {
visitor.visit_value_and_done(BorrowedStatic(&2));
Ok(())
@@ -76,7 +76,7 @@ fn value_builder_can_use_an_owned_value_or_a_borrowed_value() {
assert_eq!(
i32::build({
- let mut walker = MockWalker::<(), (), Blocking>::new();
+ let mut walker = MockWalker::<(), (), BlockingSpin>::new();
walker.expect_walk().once().returning(|mut visitor| {
visitor.visit_value_and_done(TempBorrowedStatic(&3));
Ok(())
diff --git a/tests/common/builder.rs b/tests/common/builder.rs
index 49f7d16..419661b 100644
--- a/tests/common/builder.rs
+++ b/tests/common/builder.rs
@@ -1,8 +1,9 @@
use core::fmt::{Debug, Display};
use effectful::{
- bound::{Bool, Dynamic, DynamicShim, IsSend, IsSync},
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
+ DynBind,
+ bound::{Bool, Dynamic, IsSend, IsSync},
+ effective::{Effective, Canonical},
+ environment::{Environment},
forward_send_sync, SendSync,
};
use mockall::mock;
@@ -36,11 +37,11 @@ mock! {
// pub fn traits(&self, id: WithLtTypeId<'_, '_>) -> &Option<Box<DynamicShim<dyn for<'ctx> AnyTrait<'ctx, E>>>>;
// pub fn traits_mut(&mut self, id: WithLtTypeId<'_, '_>) -> &mut Option<Box<DynamicShim<dyn for<'ctx> AnyTrait<'ctx, E>>>>;
- pub fn traits_mut(&mut self) -> &mut Box<dyn for<'a, 'ctx> FnMut(WithLtTypeId<'a, 'ctx>) -> Option<MutAnyUnsized<'a, 'a, 'ctx>>>;
+ pub fn traits_mut(&mut self) -> &mut Box<dyn for<'a, 'ctx> FnMut(WithLtTypeId<'a, 'ctx>) -> Option<MutAnyUnsized<'a, 'a, 'ctx>> + Send>;
}
}
-forward_send_sync!({Seed: ('static), Error: ('static)} {} {Value: ('static), E: (Environment)} MockBuilder<Seed, Value, Error, E>);
+forward_send_sync!({Seed: ('static), Error: ('static)} {} {Value: ('static + Send), E: (Environment + Send)} MockBuilder<Seed, Value, Error, E>);
impl<Seed, Value, Error: Display + Debug, E: Environment> BuilderTypes<E>
for MockBuilder<Seed, Value, Error, E>
@@ -78,19 +79,19 @@ impl<Seed: 'static, Value: 'static, Error: 'static, E: Environment>
}
}
-impl<'ctx, Seed: DynBind<E>, Value, Error: DynBind<E> + Display + Debug, E: Environment>
+impl<'ctx, Seed: DynBind<E>, Value: Send, Error: DynBind<E> + Display + Debug, E: Environment + Send>
Builder<'ctx, E> for MockBuilder<Seed, Value, Error, E>
where
Dynamic<Value>: DynBind<E>,
{
- fn from_seed<'a>(seed: Self::Seed) -> NativeForm<'a, Self, E>
+ fn from_seed<'a>(seed: Self::Seed) -> Canonical<'a, Self, E>
where
Self: 'a,
{
E::value(Self::from_seed(seed)).cast()
}
- fn build<'a>(self) -> NativeForm<'a, Result<Self::Output, Self::Error>, E>
+ fn build<'a>(self) -> Canonical<'a, Result<Self::Output, Self::Error>, E>
where
Self: 'a,
{
@@ -98,7 +99,7 @@ where
}
}
-impl<'ctx, Seed, Value, Error: Display + Debug, E: Environment> AsVisitor<'ctx, E>
+impl<'ctx, Seed, Value: Send, Error: Display + Debug, E: Environment + Send> AsVisitor<'ctx, E>
for MockBuilder<Seed, Value, Error, E>
where
Seed: DynBind<E>,
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 2775f44..bb619b3 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -11,9 +11,7 @@ use std::{
sync::{Mutex, MutexGuard, OnceLock, RwLock},
};
-use effectful::{block_on::Spin, blocking::Blocking as Block, bound::No, environment::Cfg};
-
-pub type Blocking = Block<Cfg<Spin, No, No>>;
+use effectful::{block_on::Spin, blocking::Blocking as Block, bound::No};
pub mod builder;
pub mod protocol;
diff --git a/tests/common/protocol/hint.rs b/tests/common/protocol/hint.rs
index abb38dd..e6e70b3 100644
--- a/tests/common/protocol/hint.rs
+++ b/tests/common/protocol/hint.rs
@@ -1,7 +1,7 @@
use effectful::{
bound::{Bool, IsSend, IsSync},
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
forward_send_sync,
higher_ranked::WithLt,
};
@@ -29,9 +29,9 @@ mock! {
}
}
-forward_send_sync!({} {} {P: (?Sized + HintMeta)} MockHintWalker<P>);
+forward_send_sync!({} {} {P: (?Sized + HintMeta + Send)} MockHintWalker<P>);
-impl<'ctx, P: ?Sized + HintMeta> AnyTrait<'ctx> for MockHintWalker<P> {
+impl<'ctx, P: ?Sized + HintMeta + Send> AnyTrait<'ctx> for MockHintWalker<P> {
fn upcast_by_id_mut<'a, 'lt: 'a>(
&'a mut self,
id: WithLtTypeId<'lt, 'ctx>,
@@ -40,10 +40,10 @@ impl<'ctx, P: ?Sized + HintMeta> AnyTrait<'ctx> for MockHintWalker<P> {
'ctx: 'lt,
{
trait_by_id!(&mut self, id, {
- type Impls<'lt, 'ctx> = (dyn Hint<P>);
+ type Impls = (dyn Hint<P>);
+ });
- None
- })
+ None
}
}
@@ -55,12 +55,12 @@ impl<'ctx, P: ?Sized + HintMeta> AnyTrait<'ctx> for MockHintWalker<P> {
// P: HintMeta<Effect = E>,
// }
-impl<'ctx, P: ?Sized + HintMeta> Hint<'ctx, P> for MockHintWalker<P> {
+impl<'ctx, P: ?Sized + HintMeta + Send> Hint<'ctx, P> for MockHintWalker<P> {
fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
&'this mut self,
visitor: DynVisitorWith<'visitor, 'ctx, P>,
hint: WithLt<'hint, <P as HintMeta>::Hint>,
- ) -> NativeForm<'e, VisitResult, <P>::Env>
+ ) -> Canonical<'e, VisitResult, <P>::Env>
where
'ctx: 'this + 'visitor + 'hint,
{
@@ -70,9 +70,9 @@ impl<'ctx, P: ?Sized + HintMeta> Hint<'ctx, P> for MockHintWalker<P> {
fn known<'a>(
&'a mut self,
hint: &'a WithLt<'a, <P as HintMeta>::Hint>,
- ) -> NativeForm<'a, Result<WithLt<'a, <P as HintMeta>::Known>, ()>, <P>::Env>
+ ) -> Canonical<'a, Result<WithLt<'a, <P as HintMeta>::Known>, ()>, <P>::Env>
where
- WithLt<'a, <P as HintMeta>::Known>: effectful::environment::DynBind<<P>::Env>,
+ WithLt<'a, <P as HintMeta>::Known>: effectful::bound::DynBind<<P>::Env>,
{
todo!()
}
@@ -81,7 +81,7 @@ impl<'ctx, P: ?Sized + HintMeta> Hint<'ctx, P> for MockHintWalker<P> {
// &'this mut self,
// visitor: DynVisitorWith<'visitor, 'ctx, P>,
// hint: WithLt<'hint, P>,
- // ) -> NativeForm<'e, VisitResult, P::Effect>
+ // ) -> Canonical<'e, VisitResult, P::Effect>
// where
// 'ctx: 'this + 'visitor + 'hint + 'e,
// {
@@ -91,7 +91,7 @@ impl<'ctx, P: ?Sized + HintMeta> Hint<'ctx, P> for MockHintWalker<P> {
// fn known<'a>(
// &'a mut self,
// hint: &'a WithLt<'a, P::Hint>,
- // ) -> NativeForm<'a, Result<WithLt<'a, P::Known>, ()>, P::Effect> {
+ // ) -> Canonical<'a, Result<WithLt<'a, P::Known>, ()>, P::Effect> {
// P::Effect::value(Self::known(self)(&(), hint)).cast()
// }
}
diff --git a/tests/common/protocol/recoverable.rs b/tests/common/protocol/recoverable.rs
index 285e960..721deec 100644
--- a/tests/common/protocol/recoverable.rs
+++ b/tests/common/protocol/recoverable.rs
@@ -1,8 +1,8 @@
use effectful::{
- blocking::Blocking as Block,
+ blocking::BlockingSpin,
bound::{Bool, IsSend, IsSync},
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
forward_send_sync,
};
use mockall::mock;
@@ -18,15 +18,13 @@ use treaty::{
Flow, Status,
};
-use crate::common::Blocking;
-
mock! {
pub RecoverableVisitor<E: Environment> {
pub fn visit<'a, 'ctx>(&mut self, scope: DynRecoverableScope<'a, 'ctx, E>) -> VisitResult;
}
}
-forward_send_sync!({} {} {E: (Environment)} MockRecoverableVisitor<E>);
+forward_send_sync!({} {} {E: (Environment + Send)} MockRecoverableVisitor<E>);
// any_trait! {
// impl['ctx][E] MockRecoverableVisitor<E> = [
@@ -35,11 +33,11 @@ forward_send_sync!({} {} {E: (Environment)} MockRecoverableVisitor<E>);
// E: Environment,
// }
-impl<'ctx, E: Environment> Recoverable<'ctx, E> for MockRecoverableVisitor<E> {
+impl<'ctx, E: Environment + Send> Recoverable<'ctx, E> for MockRecoverableVisitor<E> {
fn visit<'a>(
&'a mut self,
scope: DynRecoverableScope<'a, 'ctx, E>,
- ) -> NativeForm<'a, VisitResult, E> {
+ ) -> Canonical<'a, VisitResult, E> {
E::value(self.visit(scope)).cast()
}
}
@@ -50,30 +48,30 @@ mock! {
}
}
-forward_send_sync!({} {} {E: (Environment)} MockRecoverableScopeVisitor<E>);
+forward_send_sync!({} {} {E: (Environment + Send)} MockRecoverableScopeVisitor<E>);
-impl<'ctx, E: Environment> RecoverableScope<'ctx, E> for MockRecoverableScopeVisitor<E> {
+impl<'ctx, E: Environment + Send> RecoverableScope<'ctx, E> for MockRecoverableScopeVisitor<E> {
fn new_walk<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Status, E> {
+ ) -> Canonical<'c, Status, E> {
E::value(self.new_walk(visitor)).cast()
}
}
pub trait RecoverableVisitorExt<'ctx> {
- fn visit_recoverable_and_done<'a>(&'a mut self, scope: DynRecoverableScope<'a, 'ctx, Blocking>);
+ fn visit_recoverable_and_done<'a>(&'a mut self, scope: DynRecoverableScope<'a, 'ctx, BlockingSpin>);
}
impl<'ctx, T> RecoverableVisitorExt<'ctx> for T
where
- T: AsVisitor<'ctx, Blocking>,
+ T: AsVisitor<'ctx, BlockingSpin>,
{
fn visit_recoverable_and_done<'a>(
&'a mut self,
- scope: DynRecoverableScope<'a, 'ctx, Blocking>,
+ scope: DynRecoverableScope<'a, 'ctx, BlockingSpin>,
) {
- let result = visit_recoverable(self.as_visitor(), scope).into_value();
+ let result = visit_recoverable(self.as_visitor(), scope).wait();
assert_eq!(result, VisitResult::Control(Flow::Done));
}
diff --git a/tests/common/protocol/request_hint.rs b/tests/common/protocol/request_hint.rs
index 4f7b7c2..88649df 100644
--- a/tests/common/protocol/request_hint.rs
+++ b/tests/common/protocol/request_hint.rs
@@ -1,7 +1,7 @@
use effectful::{
bound::{Bool, IsSend, IsSync},
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
forward_send_sync,
};
use mockall::mock;
@@ -18,7 +18,7 @@ mock! {
}
}
-forward_send_sync!({} {} {E: (Environment)} MockRequestHintVisitor<E>);
+forward_send_sync!({} {} {E: (Environment + Send)} MockRequestHintVisitor<E>);
// any_trait! {
// impl['ctx][E] MockRequestHintVisitor<E> = [
@@ -27,11 +27,11 @@ forward_send_sync!({} {} {E: (Environment)} MockRequestHintVisitor<E>);
// E: Environment,
// }
-impl<'ctx, E: Environment> RequestHint<'ctx, E> for MockRequestHintVisitor<E> {
+impl<'ctx, E: Environment + Send> RequestHint<'ctx, E> for MockRequestHintVisitor<E> {
fn request_hint<'this: 'e, 'walker: 'e, 'e>(
&'this mut self,
walker: DynWalker<'walker, 'ctx, E>,
- ) -> NativeForm<'e, VisitResult, E>
+ ) -> Canonical<'e, VisitResult, E>
where
'ctx: 'this + 'walker,
{
diff --git a/tests/common/protocol/sequence.rs b/tests/common/protocol/sequence.rs
index 3ebc13f..dfc2b36 100644
--- a/tests/common/protocol/sequence.rs
+++ b/tests/common/protocol/sequence.rs
@@ -1,7 +1,7 @@
use effectful::{
bound::{Bool, IsSend, IsSync},
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
forward_send_sync,
};
use mockall::mock;
@@ -21,7 +21,7 @@ mock! {
}
}
-forward_send_sync!({} {} {E: (Environment)} MockSequenceVisitor<E>);
+forward_send_sync!({} {} {E: (Environment + Send)} MockSequenceVisitor<E>);
// any_trait! {
// impl['ctx][E] MockSequenceVisitor<E> = [
@@ -30,11 +30,11 @@ forward_send_sync!({} {} {E: (Environment)} MockSequenceVisitor<E>);
// E: Environment,
// }
-impl<'ctx, E: Environment> Sequence<'ctx, E> for MockSequenceVisitor<E> {
+impl<'ctx, E: Environment + Send> Sequence<'ctx, E> for MockSequenceVisitor<E> {
fn visit<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
scope: DynSequenceScope<'b, 'ctx, E>,
- ) -> NativeForm<'c, VisitResult, E> {
+ ) -> Canonical<'c, VisitResult, E> {
E::value(self.visit(scope)).cast()
}
}
@@ -46,17 +46,17 @@ mock! {
}
}
-forward_send_sync!({} {} {E: (Environment)} MockSequenceScope<E>);
+forward_send_sync!({} {} {E: (Environment + Send)} MockSequenceScope<E>);
-impl<'ctx, E: Environment> SequenceScope<'ctx, E> for MockSequenceScope<E> {
- fn size_hint(&mut self) -> NativeForm<'_, (usize, Option<usize>), E> {
+impl<'ctx, E: Environment + Send> SequenceScope<'ctx, E> for MockSequenceScope<E> {
+ fn size_hint(&mut self) -> Canonical<'_, (usize, Option<usize>), E> {
E::value(self.size_hint()).cast()
}
fn next<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
visitor: DynVisitor<'b, 'ctx, E>,
- ) -> NativeForm<'c, Flow, E> {
+ ) -> Canonical<'c, Flow, E> {
E::value(self.next(visitor)).cast()
}
}
diff --git a/tests/common/protocol/tag.rs b/tests/common/protocol/tag.rs
index a1811df..cd79a05 100644
--- a/tests/common/protocol/tag.rs
+++ b/tests/common/protocol/tag.rs
@@ -1,7 +1,8 @@
use effectful::{
bound::{Bool, IsSend, IsSync},
- effective::Effective,
- environment::{Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
+ blocking::BlockingSpin,
forward_send_sync,
};
use mockall::mock;
@@ -15,15 +16,13 @@ use treaty::{
Flow, Walker,
};
-use crate::common::Blocking;
-
mock! {
pub TagVisitor<K: TagKind<E>, E: Environment> {
pub fn visit<'a, 'ctx>(&'a mut self, kind: K, walker: DynWalkerObjSafe<'a, 'ctx, E>) -> VisitResult;
}
}
-forward_send_sync!({K: (TagKind<E>)} {} {E: (Environment)} MockTagVisitor<K, E>);
+forward_send_sync!({K: (TagKind<E> + Send)} {} {E: (Environment + Send)} MockTagVisitor<K, E>);
// any_trait! {
// impl['ctx, K][E] MockTagVisitor<K, E> = [
@@ -33,18 +32,18 @@ forward_send_sync!({K: (TagKind<E>)} {} {E: (Environment)} MockTagVisitor<K, E>)
// E: Environment,
// }
-impl<'ctx, K: TagKind<E>, E: Environment> Tag<'ctx, K, E> for MockTagVisitor<K, E> {
+impl<'ctx, K: TagKind<E> + Send, E: Environment + Send> Tag<'ctx, K, E> for MockTagVisitor<K, E> {
fn visit<'a: 'c, 'b: 'c, 'c>(
&'a mut self,
kind: K,
walker: DynWalkerObjSafe<'b, 'ctx, E>,
- ) -> NativeForm<'c, VisitResult, E> {
+ ) -> Canonical<'c, VisitResult, E> {
E::value(self.visit(kind, walker)).cast()
}
}
pub trait TagVisitorExt<'ctx> {
- fn visit_tag_and_done<'a, T: ConstTagKind<Blocking>, W: Walker<'ctx, Blocking>>(
+ fn visit_tag_and_done<'a, T: ConstTagKind<BlockingSpin>, W: Walker<'ctx, BlockingSpin>>(
&'a mut self,
walker: W,
);
@@ -52,14 +51,14 @@ pub trait TagVisitorExt<'ctx> {
impl<'ctx, T> TagVisitorExt<'ctx> for T
where
- T: AsVisitor<'ctx, Blocking>,
+ T: AsVisitor<'ctx, BlockingSpin>,
{
- fn visit_tag_and_done<'a, Tag: ConstTagKind<Blocking>, W: Walker<'ctx, Blocking>>(
+ fn visit_tag_and_done<'a, Tag: ConstTagKind<BlockingSpin>, W: Walker<'ctx, BlockingSpin>>(
&'a mut self,
walker: W,
) {
let result =
- visit_tag::<Tag, Blocking, _>(Tag::NEW, self.as_visitor(), walker).into_value();
+ visit_tag::<Tag, BlockingSpin, _>(Tag::NEW, self.as_visitor(), walker).wait();
assert_eq!(result.unwrap(), VisitResult::Control(Flow::Done));
}
diff --git a/tests/common/protocol/value.rs b/tests/common/protocol/value.rs
index 6897a94..a3f4dbb 100644
--- a/tests/common/protocol/value.rs
+++ b/tests/common/protocol/value.rs
@@ -1,7 +1,9 @@
use effectful::{
bound::{Bool, Dynamic, IsSend, IsSync},
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{ Environment},
+ DynBind,
+ blocking::BlockingSpin,
forward_send_sync,
};
use mockall::mock;
@@ -14,8 +16,6 @@ use treaty::{
Flow,
};
-use crate::common::Blocking;
-
mock! {
pub ValueVisitor<T: type_name::Static>
where
@@ -25,7 +25,7 @@ mock! {
}
}
-forward_send_sync!({} {} {T: (type_name::Static)} MockValueVisitor<T> where {
+forward_send_sync!({} {} {T: (type_name::Static + Send)} MockValueVisitor<T> where {
for<'a, 'ctx> type_name::Lowered<'a, 'ctx, T>: Sized
});
@@ -39,14 +39,14 @@ forward_send_sync!({} {} {T: (type_name::Static)} MockValueVisitor<T> where {
// E: Environment,
// }
-impl<'ctx, T: type_name::Static, E: Environment> Value<'ctx, T, E> for MockValueVisitor<T>
+impl<'ctx, T: type_name::Static + Send, E: Environment> Value<'ctx, T, E> for MockValueVisitor<T>
where
for<'a, 'b> type_name::Lowered<'a, 'b, T>: Sized,
{
fn visit<'this: 'value, 'value: 'e, 'e>(
&'this mut self,
value: type_name::Lowered<'value, 'ctx, T>,
- ) -> NativeForm<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, T>>>, E>
+ ) -> Canonical<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, T>>>, E>
where
// type_name::Lowered<'value, 'ctx, T>: Sized,
Dynamic<type_name::Lowered<'value, 'ctx, T>>: DynBind<E>,
@@ -58,7 +58,7 @@ where
// fn visit<'a>(
// &'a mut self,
// value: TypeName::T<'a, 'ctx, T, E>,
- // ) -> NativeForm<'a, VisitResult<Dynamic<TypeName::T<'a, 'ctx, T, E>>>, E>
+ // ) -> Canonical<'a, VisitResult<Dynamic<TypeName::T<'a, 'ctx, T, E>>>, E>
// where
// 'ctx: 'a,
// {
@@ -86,7 +86,7 @@ pub trait ValueVisitorExt<'ctx> {
impl<'ctx, U> ValueVisitorExt<'ctx> for U
where
- U: AsVisitor<'ctx, Blocking>,
+ U: AsVisitor<'ctx, BlockingSpin>,
{
#[track_caller]
fn visit_value_and_done<'a, T>(&'a mut self, value: T)
@@ -95,7 +95,7 @@ where
type_name::Raised<'a, 'ctx, T>: type_name::Static,
'ctx: 'a,
{
- let result = visit_value::<_, Blocking>(self.as_visitor(), value).into_value();
+ let result = visit_value::<_, BlockingSpin>(self.as_visitor(), value).wait();
assert_eq!(result, VisitResult::Control(Flow::Done));
}
@@ -113,11 +113,11 @@ where
// #[track_caller]
// fn visit_value_and_done<'a, T>(&'a mut self, value: T)
// where
- // T: TypeName::LowerType<'a, 'ctx, Blocking>,
- // TypeName::HigherRanked<'a, 'ctx, T, Blocking>: TypeName::MemberType<Blocking>,
+ // T: TypeName::LowerType<'a, 'ctx, BlockingSpin>,
+ // TypeName::HigherRanked<'a, 'ctx, T, BlockingSpin>: TypeName::MemberType<BlockingSpin>,
// 'ctx: 'a,
// {
- // let result = visit_value::<_, Blocking>(self.as_visitor(), value).into_value();
+ // let result = visit_value::<_, BlockingSpin>(self.as_visitor(), value).into_value();
//
// assert_eq!(result, VisitResult::Control(Flow::Done));
// }
@@ -125,11 +125,11 @@ where
// #[track_caller]
// fn visit_value_and_skipped<'a, T>(&'a mut self, value: T)
// where
- // T: TypeName::LowerType<'a, 'ctx, Blocking>,
- // TypeName::HigherRanked<'a, 'ctx, T, Blocking>: TypeName::MemberType<Blocking>,
+ // T: TypeName::LowerType<'a, 'ctx, BlockingSpin>,
+ // TypeName::HigherRanked<'a, 'ctx, T, BlockingSpin>: TypeName::MemberType<BlockingSpin>,
// 'ctx: 'a,
// {
- // let result = visit_value::<_, Blocking>(self.as_visitor(), value).into_value();
+ // let result = visit_value::<_, BlockingSpin>(self.as_visitor(), value).into_value();
//
// assert_eq!(result.unit_skipped(), VisitResult::Skipped(()));
// }
diff --git a/tests/common/walker.rs b/tests/common/walker.rs
index 41495a1..c2e15b3 100644
--- a/tests/common/walker.rs
+++ b/tests/common/walker.rs
@@ -1,7 +1,8 @@
use effectful::{
bound::{Bool, IsSend, IsSync},
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
+ effective::{Effective, Canonical},
+ environment::{Environment},
+ DynBind,
forward_send_sync,
};
use mockall::mock;
@@ -17,9 +18,9 @@ mock! {
}
}
-forward_send_sync!({Output, Error} {} {E: (Environment)} MockWalker<Output, Error, E>);
+forward_send_sync!({Output, Error} {} {E: (Environment + Send)} MockWalker<Output, Error, E>);
-impl<'ctx, Output: DynBind<E>, Error: DynBind<E> + core::fmt::Debug, E: Environment> Walker<'ctx, E>
+impl<'ctx, Output: DynBind<E>, Error: DynBind<E> + core::fmt::Debug, E: Environment + Send> Walker<'ctx, E>
for MockWalker<Output, Error, E>
{
type Error = Error;
@@ -29,7 +30,7 @@ impl<'ctx, Output: DynBind<E>, Error: DynBind<E> + core::fmt::Debug, E: Environm
fn walk<'a: 'c, 'c>(
self,
visitor: DynVisitor<'a, 'ctx, E>,
- ) -> NativeForm<'c, Result<Self::Output, Self::Error>, E>
+ ) -> Canonical<'c, Result<Self::Output, Self::Error>, E>
where
Self: 'c,
{
diff --git a/tests/protocol_visitor_recoverable.rs b/tests/protocol_visitor_recoverable.rs
index 3243f2c..9c2e7d0 100644
--- a/tests/protocol_visitor_recoverable.rs
+++ b/tests/protocol_visitor_recoverable.rs
@@ -1,4 +1,5 @@
use common::protocol::recoverable::MockRecoverableVisitor;
+use effectful::blocking::BlockingSpin;
use treaty::{
any::OwnedStatic,
protocol::{
@@ -9,7 +10,7 @@ use treaty::{
};
use crate::common::{
- builder::MockBuilder, protocol::recoverable::MockRecoverableScopeVisitor, Blocking,
+ builder::MockBuilder, protocol::recoverable::MockRecoverableScopeVisitor,
};
mod common;
@@ -17,11 +18,11 @@ mod common;
/// Tests that the recoverable protocol allows multiple walks by the visitor.
#[test]
fn recoverable_can_be_visited() {
- let mut mock = MockRecoverableVisitor::<Blocking>::new();
+ let mut mock = MockRecoverableVisitor::<BlockingSpin>::new();
// Expect a visit using the rescoverable protocol.
mock.expect_visit().once().returning(|scope| {
- let mut visitor = MockBuilder::<(), (), (), Blocking>::new();
+ let mut visitor = MockBuilder::<(), (), (), BlockingSpin>::new();
// Expect that the visitor gets used.
visitor.expect_traits().times(2).return_const(None);
@@ -42,7 +43,7 @@ fn recoverable_can_be_visited() {
VisitResult::Control(Flow::Done)
});
- let visitor: &mut dyn Recoverable<Blocking> = &mut mock;
+ let visitor: &mut dyn Recoverable<BlockingSpin> = &mut mock;
let mut scope = MockRecoverableScopeVisitor::new();
@@ -50,7 +51,7 @@ fn recoverable_can_be_visited() {
scope.expect_new_walk().times(2).returning(|visitor| {
// Attempt to use the visitor.
assert!(visitor
- .upcast::<ValueProto<OwnedStatic<i32>, Blocking>>()
+ .upcast::<ValueProto<OwnedStatic<i32>, BlockingSpin>>()
.is_none());
Status::Ok
diff --git a/tests/protocol_visitor_request_hint.rs b/tests/protocol_visitor_request_hint.rs
index f43f2d5..52b4c2a 100644
--- a/tests/protocol_visitor_request_hint.rs
+++ b/tests/protocol_visitor_request_hint.rs
@@ -1,5 +1,6 @@
use std::any::TypeId;
+use effectful::blocking::BlockingSpin;
use common::{
protocol::{hint::MockHintWalker, request_hint::MockRequestHintVisitor},
walker::MockWalker,
@@ -14,20 +15,20 @@ use treaty::{
Flow,
};
-use crate::common::{protocol::hint::KnownFactory, Blocking};
+use crate::common::{protocol::hint::KnownFactory};
use effectful::bound::Dynamic;
mod common;
#[test]
fn hints_can_be_requested() {
- let mut mock = MockRequestHintVisitor::<Blocking>::new();
+ let mut mock = MockRequestHintVisitor::<BlockingSpin>::new();
// We will request a hint from the visitor.
mock.expect_request_hint().once().returning(|mut walker| {
// Lookup the value protocol on the walker.
let obj = walker
- .upcast_mut::<HintProto<ValueProto<OwnedStatic<i32>, Blocking>>>()
+ .upcast_mut::<HintProto<ValueProto<OwnedStatic<i32>, BlockingSpin>>>()
.unwrap();
// Get the known for the value protocol.
@@ -43,19 +44,19 @@ fn hints_can_be_requested() {
});
// This mock becomes the visitor.
- let visitor: &mut dyn RequestHint<Blocking> = &mut mock;
+ let visitor: &mut dyn RequestHint<BlockingSpin> = &mut mock;
- let mut mock = MockWalker::<(), (), Blocking>::new();
+ let mut mock = MockWalker::<(), (), BlockingSpin>::new();
// The visitor will lookup the value protocol on the walker.
mock.expect_traits_mut()
.once()
.with(eq(TypeNameId::of::<
- HintProto<ValueProto<OwnedStatic<i32>, Blocking>>,
- Blocking,
+ HintProto<ValueProto<OwnedStatic<i32>, BlockingSpin>>,
+ BlockingSpin,
>()))
.returning(|_id| {
- let mut mock = MockHintWalker::<ValueProto<OwnedStatic<i32>, Blocking>>::new();
+ let mut mock = MockHintWalker::<ValueProto<OwnedStatic<i32>, BlockingSpin>>::new();
// Expect to give a known for the value protocol to the visitor.
mock.expect_known().once().return_const(
@@ -63,7 +64,7 @@ fn hints_can_be_requested() {
Ok(ValueKnown {
preview: Some(Dynamic(&OwnedStatic(42))),
})
- }) as KnownFactory<ValueProto<OwnedStatic<i32>, Blocking>>,
+ }) as KnownFactory<ValueProto<OwnedStatic<i32>, BlockingSpin>>,
);
Some(Box::new(mock))
@@ -79,10 +80,10 @@ fn hints_can_be_requested() {
#[test]
fn request_hint_proto() {
// The type id of the higher ranked type.
- let id = TypeId::of::<RequestHintProto<Blocking>>();
+ let id = TypeId::of::<RequestHintProto<BlockingSpin>>();
// The type id for the lifetime containing value protocol trait object.
- let name_id = TypeNameId::of_lower::<dyn RequestHint<Blocking>, Blocking>();
+ let name_id = TypeNameId::of_lower::<dyn RequestHint<BlockingSpin>, BlockingSpin>();
// They should be the same.
assert_eq!(id, name_id.into_type_id());
diff --git a/tests/protocol_visitor_sequence.rs b/tests/protocol_visitor_sequence.rs
index ab4d694..49f6317 100644
--- a/tests/protocol_visitor_sequence.rs
+++ b/tests/protocol_visitor_sequence.rs
@@ -1,4 +1,5 @@
use std::any::TypeId;
+use effectful::blocking::BlockingSpin;
use common::protocol::sequence::{MockSequenceScope, MockSequenceVisitor};
use treaty::{
@@ -10,20 +11,20 @@ use treaty::{
Flow,
};
-use crate::common::{builder::MockBuilder, Blocking};
+use crate::common::{builder::MockBuilder};
mod common;
#[test]
fn sequence_has_scope_with_size_hint_and_next() {
- let mut mock = MockSequenceVisitor::<Blocking>::new();
+ let mut mock = MockSequenceVisitor::<BlockingSpin>::new();
// Expect a visit with the sequence protocol.
mock.expect_visit().once().returning(|scope| {
// Get the size hint from the sequence scope.
assert_eq!(scope.size_hint().into_value(), (1, Some(1)));
- let mut visitor = MockBuilder::<(), (), (), Blocking>::new();
+ let mut visitor = MockBuilder::<(), (), (), BlockingSpin>::new();
// Expect the walker to lookup a trait.
visitor.expect_traits().once().return_const(None);
@@ -39,9 +40,9 @@ fn sequence_has_scope_with_size_hint_and_next() {
});
// Everything goes throw the sequence protocol trait.
- let visitor: &mut dyn Sequence<Blocking> = &mut mock;
+ let visitor: &mut dyn Sequence<BlockingSpin> = &mut mock;
- let mut scope = MockSequenceScope::<Blocking>::new();
+ let mut scope = MockSequenceScope::<BlockingSpin>::new();
// Expect a size hint to be asked for.
scope.expect_size_hint().once().return_const((1, Some(1)));
@@ -50,7 +51,7 @@ fn sequence_has_scope_with_size_hint_and_next() {
scope.expect_next().once().returning(|visitor| {
// Attempt to lookup a trait on the visitor.
assert!(visitor
- .upcast::<ValueProto<OwnedStatic<i32>, Blocking>>()
+ .upcast::<ValueProto<OwnedStatic<i32>, BlockingSpin>>()
.is_none());
// We are done.
@@ -67,10 +68,10 @@ fn sequence_has_scope_with_size_hint_and_next() {
#[test]
fn sequence_proto() {
// The type id of the higher ranked type.
- let id = TypeId::of::<SequenceProto<Blocking>>();
+ let id = TypeId::of::<SequenceProto<BlockingSpin>>();
// The type id for the lifetime containing value protocol trait object.
- let name_id = TypeNameId::of_lower::<dyn Sequence<Blocking>, Blocking>();
+ let name_id = TypeNameId::of_lower::<dyn Sequence<BlockingSpin>, BlockingSpin>();
// They should be the same.
assert_eq!(id, name_id.into_type_id());
diff --git a/tests/protocol_visitor_tag.rs b/tests/protocol_visitor_tag.rs
index fb0d6c0..e37b819 100644
--- a/tests/protocol_visitor_tag.rs
+++ b/tests/protocol_visitor_tag.rs
@@ -1,10 +1,11 @@
use std::any::TypeId;
use common::protocol::tag::MockTagVisitor;
+use effectful::{blocking::BlockingSpin, Effective as _};
use treaty::{
- any::OwnedStatic,
+ any::{OwnedStatic, WithLtTypeId},
protocol::{
- visitor::{Tag, TagConst, TagDyn, VisitResult},
+ visitor::{Tag, TagConst, TagDyn, Value, VisitResult},
DynVisitor,
},
symbol::Symbol,
@@ -12,14 +13,14 @@ use treaty::{
Flow,
};
-use crate::common::{builder::MockBuilder, walker::MockWalker, Blocking};
+use crate::common::{builder::MockBuilder, walker::MockWalker};
mod common;
/// Tests that the tag protocol can be visited with a value walker.
#[test]
fn tag_can_be_visited() {
- let mut mock = MockTagVisitor::<TagDyn, Blocking>::new();
+ let mut mock = MockTagVisitor::<TagDyn, BlockingSpin>::new();
// Expect a visit with the tag protocol.
mock.expect_visit()
@@ -28,14 +29,14 @@ fn tag_can_be_visited() {
// The kind should be test.
assert_eq!(kind, Symbol::new("test"));
- let mut builder = MockBuilder::<(), (), (), Blocking>::new();
+ let mut builder = MockBuilder::<(), (), (), BlockingSpin>::new();
// Expect that the builder is attempted to be used by the walker for the value.
- builder.expect_traits().once().return_const(None);
+ builder.expect_traits_mut().once().return_const(None);
// Walk the value of the tag.
assert_eq!(
- walker.walk(DynVisitor(&mut builder)).into_value(),
+ walker.walk(DynVisitor(&mut builder)).wait(),
Flow::Done
);
@@ -44,15 +45,15 @@ fn tag_can_be_visited() {
});
// Use the tag protocol trait.
- let visitor: &mut dyn Tag<TagDyn, Blocking> = &mut mock;
+ let visitor: &mut dyn Tag<TagDyn, BlockingSpin> = &mut mock;
- let mut walker = MockWalker::<(), (), Blocking>::new();
+ let mut walker = MockWalker::<(), (), BlockingSpin>::new();
// Expect the tag value to be walked.
walker.expect_walk().once().returning(|visitor| {
// Attempt to use the visitor.
assert!(visitor
- .upcast::<ValueProto<OwnedStatic<i32>, Blocking>>()
+ .upcast::<dyn Value<OwnedStatic<i32>, BlockingSpin>>()
.is_none());
Ok(())
@@ -65,7 +66,7 @@ fn tag_can_be_visited() {
assert!(matches!(
visitor
.visit(TagDyn(Symbol::new("test")), &mut walker)
- .into_value(),
+ .wait(),
VisitResult::Control(Flow::Done)
));
}
@@ -75,18 +76,18 @@ fn tag_can_be_visited() {
fn const_tag_can_be_visited() {
const TEST: u64 = Symbol::new("test").to_int();
- let mut mock = MockTagVisitor::<TagConst<TEST>, Blocking>::new();
+ let mut mock = MockTagVisitor::<TagConst<TEST>, BlockingSpin>::new();
// Expect a visit with the tag protocol.
mock.expect_visit().once().returning(|TagConst, walker| {
- let mut builder = MockBuilder::<(), (), (), Blocking>::new();
+ let mut builder = MockBuilder::<(), (), (), BlockingSpin>::new();
// Expect that the builder is attempted to be used by the walker for the value.
- builder.expect_traits().once().return_const(None);
+ builder.expect_traits_mut().once().return_const(None);
// Walk the value of the tag.
assert_eq!(
- walker.walk(DynVisitor(&mut builder)).into_value(),
+ walker.walk(DynVisitor(&mut builder)).wait(),
Flow::Done
);
@@ -95,15 +96,15 @@ fn const_tag_can_be_visited() {
});
// Use the tag protocol trait.
- let visitor: &mut dyn Tag<TagConst<TEST>, Blocking> = &mut mock;
+ let visitor: &mut dyn Tag<TagConst<TEST>, BlockingSpin> = &mut mock;
- let mut walker = MockWalker::<(), (), Blocking>::new();
+ let mut walker = MockWalker::<(), (), BlockingSpin>::new();
// Expect the tag value to be walked.
walker.expect_walk().once().returning(|visitor| {
// Attempt to use the visitor.
assert!(visitor
- .upcast::<ValueProto<OwnedStatic<i32>, Blocking>>()
+ .upcast::<dyn Value<OwnedStatic<i32>, BlockingSpin>>()
.is_none());
Ok(())
@@ -114,7 +115,7 @@ fn const_tag_can_be_visited() {
// Visit the tag protocol for kind test with the value walker.
assert!(matches!(
- visitor.visit(TagConst, &mut walker).into_value(),
+ visitor.visit(TagConst, &mut walker).wait(),
VisitResult::Control(Flow::Done)
));
}
@@ -122,11 +123,11 @@ fn const_tag_can_be_visited() {
#[test]
fn tag_proto() {
// The type id of the higher ranked type.
- let id = TypeId::of::<TagProto<TagDyn, Blocking>>();
+ let id = TypeId::of::<dyn Tag<TagDyn, BlockingSpin>>();
// The type id for the lifetime containing value protocol trait object.
- let name_id = TypeNameId::of_lower::<dyn Tag<TagDyn, Blocking>, Blocking>();
+ let name_id = WithLtTypeId::of::<dyn Tag<TagDyn, BlockingSpin>>();
- // They should be the same.
- assert_eq!(id, name_id.into_type_id());
+ // // They should be the same.
+ // assert_eq!(id, name_id.into_type_id());
}
diff --git a/tests/protocol_visitor_value.rs b/tests/protocol_visitor_value.rs
index 17ba3fe..82db58f 100644
--- a/tests/protocol_visitor_value.rs
+++ b/tests/protocol_visitor_value.rs
@@ -6,6 +6,7 @@ use common::protocol::{
};
use effectful::bound::Dynamic;
use effectful::SendSync;
+use effectful::blocking::BlockingSpin;
use mockall::predicate::eq;
use treaty::{
any::{AnyTrait, BorrowedStatic, OwnedStatic, TempBorrowedMutStatic},
@@ -17,8 +18,6 @@ use treaty::{
Flow,
};
-use crate::common::Blocking;
-
mod common;
/// Tests support for custom type support in the value protocol.
@@ -30,7 +29,7 @@ fn custom_value_type() {
#[derive(PartialEq, Debug, Clone, SendSync)]
struct MyValue;
- let mut mock = MockValueVisitor::<OwnedStatic<MyValue>, Blocking>::new();
+ let mut mock = MockValueVisitor::<OwnedStatic<MyValue>, BlockingSpin>::new();
// Expect the visit method to be called once with the custom type.
mock.expect_visit()
@@ -40,7 +39,7 @@ fn custom_value_type() {
// Cast to a trait object for the value protocol.
// This shows the visit method is going through the trait.
- let visitor: &mut dyn Value<OwnedStatic<MyValue>, Blocking> = &mut mock;
+ let visitor: &mut dyn Value<OwnedStatic<MyValue>, BlockingSpin> = &mut mock;
// Visit the value.
let result = visitor.visit(OwnedStatic(MyValue)).into_value();
@@ -48,9 +47,9 @@ fn custom_value_type() {
// The mock returns that it is done.
assert_eq!(result, VisitResult::Control(Flow::Done));
- let visitor: &mut dyn AnyTrait<Blocking> = &mut mock;
+ let visitor: &mut dyn AnyTrait<BlockingSpin> = &mut mock;
assert_eq!(
- visit_value::<_, Blocking>(DynVisitor(visitor), OwnedStatic(MyValue)).into_value(),
+ visit_value::<_, BlockingSpin>(DynVisitor(visitor), OwnedStatic(MyValue)).into_value(),
VisitResult::Control(Flow::Done)
);
}
@@ -70,7 +69,7 @@ fn borrowed_value() {
// We borrow the context, this is what we pass to the visitor.
let value = &context;
- let mut mock = MockValueVisitor::<BorrowedStaticHrt<String>, Blocking>::new();
+ let mut mock = MockValueVisitor::<BorrowedStaticHrt<String>, BlockingSpin>::new();
// Expect the visit method to be called once with the borrowed value.
mock.expect_visit()
@@ -79,7 +78,7 @@ fn borrowed_value() {
.return_const(VisitResult::Control(Flow::Done));
// Cast to a trait object for the value protocol.
- let visitor: &mut dyn Value<BorrowedStaticHrt<String>, Blocking> = &mut mock;
+ let visitor: &mut dyn Value<BorrowedStaticHrt<String>, BlockingSpin> = &mut mock;
// Visit the borrowed value.
assert_eq!(
@@ -87,9 +86,9 @@ fn borrowed_value() {
Flow::Done.into()
);
- let visitor: &mut dyn AnyTrait<Blocking> = &mut mock;
+ let visitor: &mut dyn AnyTrait<BlockingSpin> = &mut mock;
assert_eq!(
- visit_value::<_, Blocking>(DynVisitor(visitor), BorrowedStatic(value)).into_value(),
+ visit_value::<_, BlockingSpin>(DynVisitor(visitor), BorrowedStatic(value)).into_value(),
VisitResult::Control(Flow::Done)
);
}
@@ -115,7 +114,7 @@ fn temp_borrowed_value() {
// We borrow the context, this is what we pass to the visitor.
let value = &mut context;
- let mut mock = MockValueVisitor::<TempBorrowedMutStaticHrt<String>, Blocking>::new();
+ let mut mock = MockValueVisitor::<TempBorrowedMutStaticHrt<String>, BlockingSpin>::new();
// Expect the visit method to be called once with the borrowed value.
mock.expect_visit()
@@ -125,7 +124,7 @@ fn temp_borrowed_value() {
// Cast to a trait object for the value protocol.
// We definitly need this for this test so the lifetime is invariant.
- let visitor: &mut dyn Value<TempBorrowedMutStaticHrt<String>, Blocking> = &mut mock;
+ let visitor: &mut dyn Value<TempBorrowedMutStaticHrt<String>, BlockingSpin> = &mut mock;
// Visit the context to show we can shorten the lifetime.
// This would also force the lifetime to be to long if this wasn't the Temp form.
@@ -159,7 +158,7 @@ fn temp_borrowed_value() {
/// Tests for the control flow returns the value protocol visit can return.
#[test]
fn all_visit_results() {
- let mut mock = MockValueVisitor::<OwnedStatic<i32>, Blocking>::new();
+ let mut mock = MockValueVisitor::<OwnedStatic<i32>, BlockingSpin>::new();
mock.expect_visit()
.once()
@@ -181,7 +180,7 @@ fn all_visit_results() {
.with(eq(OwnedStatic(3)))
.return_const(VisitResult::Skipped(()));
- let visitor: &mut dyn Value<OwnedStatic<i32>, Blocking> = &mut mock;
+ let visitor: &mut dyn Value<OwnedStatic<i32>, BlockingSpin> = &mut mock;
// Visit can return a done.
assert_eq!(
@@ -214,10 +213,10 @@ fn all_visit_results() {
#[test]
fn value_proto() {
// The type id of the higher ranked type.
- let id = TypeId::of::<ValueProto<OwnedStatic<i32>, Blocking>>();
+ let id = TypeId::of::<ValueProto<OwnedStatic<i32>, BlockingSpin>>();
// The type id for the lifetime containing value protocol trait object.
- let name_id = TypeNameId::of_lower::<dyn Value<OwnedStatic<i32>, Blocking>, Blocking>();
+ let name_id = TypeNameId::of_lower::<dyn Value<OwnedStatic<i32>, BlockingSpin>, BlockingSpin>();
// They should be the same.
assert_eq!(id, name_id.into_type_id());
@@ -229,17 +228,17 @@ fn value_proto() {
#[test]
fn as_hint() {
{
- let mut mock = MockHintWalker::<ValueProto<OwnedStatic<i32>, Blocking>>::new();
+ let mut mock = MockHintWalker::<ValueProto<OwnedStatic<i32>, BlockingSpin>>::new();
mock.expect_known().once().return_const(
(|_, _hint| {
Ok(ValueKnown {
preview: Some(Dynamic(&OwnedStatic(42))),
})
- }) as KnownFactory<ValueProto<OwnedStatic<i32>, Blocking>>,
+ }) as KnownFactory<ValueProto<OwnedStatic<i32>, BlockingSpin>>,
);
- let walker: &mut dyn Hint<ValueProto<OwnedStatic<i32>, Blocking>> = &mut mock;
+ let walker: &mut dyn Hint<ValueProto<OwnedStatic<i32>, BlockingSpin>> = &mut mock;
// The value protocol has no hint data, and it has no known data.
assert_eq!(
@@ -251,17 +250,17 @@ fn as_hint() {
}
{
- let mut mock = MockHintWalker::<ValueProto<BorrowedStaticHrt<i32>, Blocking>>::new();
+ let mut mock = MockHintWalker::<ValueProto<BorrowedStaticHrt<i32>, BlockingSpin>>::new();
mock.expect_known().once().return_const(
(|_, _hint| {
Ok(ValueKnown {
preview: Some(Dynamic(&BorrowedStatic(&42))),
})
- }) as KnownFactory<ValueProto<BorrowedStaticHrt<i32>, Blocking>>,
+ }) as KnownFactory<ValueProto<BorrowedStaticHrt<i32>, BlockingSpin>>,
);
- let walker: &mut dyn Hint<ValueProto<BorrowedStaticHrt<i32>, Blocking>> = &mut mock;
+ let walker: &mut dyn Hint<ValueProto<BorrowedStaticHrt<i32>, BlockingSpin>> = &mut mock;
// The value protocol has no hint data, and it has no known data.
assert_eq!(
@@ -273,14 +272,14 @@ fn as_hint() {
}
{
- let mut mock = MockHintWalker::<ValueProto<TempBorrowedMutStaticHrt<i32>, Blocking>>::new();
+ let mut mock = MockHintWalker::<ValueProto<TempBorrowedMutStaticHrt<i32>, BlockingSpin>>::new();
mock.expect_known().once().return_const(
(|_, _hint| Ok(ValueKnown { preview: None }))
- as KnownFactory<ValueProto<TempBorrowedMutStaticHrt<i32>, Blocking>>,
+ as KnownFactory<ValueProto<TempBorrowedMutStaticHrt<i32>, BlockingSpin>>,
);
- let walker: &mut dyn Hint<ValueProto<TempBorrowedMutStaticHrt<i32>, Blocking>> = &mut mock;
+ let walker: &mut dyn Hint<ValueProto<TempBorrowedMutStaticHrt<i32>, BlockingSpin>> = &mut mock;
// The value protocol has no hint data, and it has no known data.
assert_eq!(
diff --git a/tests/protocol_walker_hint.rs b/tests/protocol_walker_hint.rs
index 723adc2..2af43ab 100644
--- a/tests/protocol_walker_hint.rs
+++ b/tests/protocol_walker_hint.rs
@@ -3,8 +3,6 @@ use std::any::TypeId;
use effectful::SendSync;
use treaty::protocol::walker::hint::{self, HintMeta};
-use crate::common::Blocking;
-
mod common;
// /// This tests for the hint protocol being able to give the known info and being able to hint.
diff --git a/tests/walker_struct.rs b/tests/walker_struct.rs
index 9872d63..9bd2a0c 100644
--- a/tests/walker_struct.rs
+++ b/tests/walker_struct.rs
@@ -1,7 +1,8 @@
use effectful::{
- bound::{Dynamic, DynamicShim, ForceDynamic},
- effective::Effective,
- environment::{DynBind, Environment, NativeForm},
+ bound::{Dynamic, ForceDynamic},
+ effective::{Effective, Canonical},
+ environment::{Environment},
+ DynBind,
SendSync,
};
use mockall::predicate::eq;
@@ -14,11 +15,11 @@ use treaty::{
walk::walkers::core::r#struct::{StructTypeInfo, StructWalker},
DefaultMode, Flow, Walker,
};
+use effectful::blocking::BlockingSpin;
use crate::common::{
builder::{EmptyError, MockBuilder},
protocol::{sequence::MockSequenceVisitor, tag::MockTagVisitor, value::MockValueVisitor},
- Blocking,
};
mod common;
@@ -51,7 +52,7 @@ where
index: usize,
value: &'ctx Self::T,
mut visitor: DynVisitor<'a, 'ctx, E>,
- ) -> NativeForm<'a, Result<Flow, Self::FieldError>, E> {
+ ) -> Canonical<'a, Result<Flow, Self::FieldError>, E> {
E::future(unsafe {
ForceDynamic::new(async move {
match index {
@@ -104,17 +105,17 @@ fn sequence_of_field_values() {
let value = X { a: true, b: 42 };
// The struct walker using the info we provided about the struct.
- let walker = StructWalker::<Info, _, DefaultMode, Blocking>::new(&value);
+ let walker = StructWalker::<Info, _, DefaultMode, BlockingSpin>::new(&value);
- let mut builder = MockBuilder::<(), (), EmptyError, Blocking>::new();
+ let mut builder = MockBuilder::<(), (), EmptyError, BlockingSpin>::new();
// Expect a visit on the sequence protocol for the struct fields.
builder
.expect_traits_mut()
.once()
- .with(eq(TypeNameId::of::<SequenceProto<Blocking>, Blocking>()))
+ .with(eq(TypeNameId::of::<SequenceProto<BlockingSpin>, BlockingSpin>()))
.returning(|_| {
- let mut visitor = MockSequenceVisitor::<Blocking>::new();
+ let mut visitor = MockSequenceVisitor::<BlockingSpin>::new();
// Expect the sequence visitor to be used.
visitor.expect_visit().once().returning(|scope| {
@@ -123,19 +124,19 @@ fn sequence_of_field_values() {
// Get the first field value.
{
- let mut visitor = MockBuilder::<(), (), EmptyError, Blocking>::new();
+ let mut visitor = MockBuilder::<(), (), EmptyError, BlockingSpin>::new();
// Expect a bool value for the field.
visitor
.expect_traits_mut()
.once()
.with(eq(TypeNameId::of::<
- ValueProto<OwnedStatic<bool>, Blocking>,
- Blocking,
+ ValueProto<OwnedStatic<bool>, BlockingSpin>,
+ BlockingSpin,
>()))
.returning(|_| {
let mut visitor =
- MockValueVisitor::<OwnedStatic<bool>, Blocking>::new();
+ MockValueVisitor::<OwnedStatic<bool>, BlockingSpin>::new();
// Expect true.
visitor
@@ -155,18 +156,18 @@ fn sequence_of_field_values() {
// Get the second field value.
{
- let mut visitor = MockBuilder::<(), (), EmptyError, Blocking>::new();
+ let mut visitor = MockBuilder::<(), (), EmptyError, BlockingSpin>::new();
// Expect a i32 value.
visitor
.expect_traits_mut()
.once()
.with(eq(TypeNameId::of::<
- ValueProto<OwnedStatic<i32>, Blocking>,
- Blocking,
+ ValueProto<OwnedStatic<i32>, BlockingSpin>,
+ BlockingSpin,
>()))
.returning(|_| {
- let mut visitor = MockValueVisitor::<OwnedStatic<i32>, Blocking>::new();
+ let mut visitor = MockValueVisitor::<OwnedStatic<i32>, BlockingSpin>::new();
// Expect a 42.
visitor
@@ -209,9 +210,9 @@ fn has_struct_tag() {
let value = X { a: true, b: 42 };
// The struct walker using the info we provided about the struct.
- let walker = StructWalker::<Info, _, DefaultMode, Blocking>::new(&value);
+ let walker = StructWalker::<Info, _, DefaultMode, BlockingSpin>::new(&value);
- let mut builder = MockBuilder::<(), (), EmptyError, Blocking>::new();
+ let mut builder = MockBuilder::<(), (), EmptyError, BlockingSpin>::new();
let mut seq = mockall::Sequence::new();
@@ -228,7 +229,7 @@ fn has_struct_tag() {
.once()
.in_sequence(&mut seq)
.with(eq(TypeNameId::of::<
- TagProto<tags::Struct, Blocking>,
+ TagProto<tags::Struct, BlockingSpin>,
Blocking,
>()))
.returning(|_| {