Diffstat (limited to 'src/build/builders/core/value.rs')
-rw-r--r--src/build/builders/core/value.rs286
1 files changed, 96 insertions, 190 deletions
diff --git a/src/build/builders/core/value.rs b/src/build/builders/core/value.rs
index ad445bb..8768567 100644
--- a/src/build/builders/core/value.rs
+++ b/src/build/builders/core/value.rs
@@ -1,16 +1,16 @@
use core::fmt::Display;
use effectful::{
- bound::Dynamic,
- effective::{Effective, Canonical},
- environment::{Environment},
- DynBind,
- SendSync,
+ bound::{Dynamic, IsSync},
+ effective::{Canonical, Effective},
+ environment::Environment,
+ DynBind, SendSync,
};
use crate::{
any::{
- type_name, AnyTrait, BorrowedMutStatic, BorrowedStatic, OwnedStatic, TempBorrowedMutStatic,
+ type_name::{self, Raised},
+ AnyTrait, BorrowedMutStatic, BorrowedStatic, OwnedStatic, TempBorrowedMutStatic,
TempBorrowedStatic,
},
hkt::Marker,
@@ -50,31 +50,31 @@ pub enum NotCloneable {}
/// After
#[derive(SendSync)]
pub struct ValueBuilder<T, Clone, E> {
- value: Option<Dynamic<T>>,
+ value: Option<T>,
_marker: Marker<(E, Clone)>,
}
impl<T, Clone, E: Environment> crate::build::BuilderTypes<E> for ValueBuilder<T, Clone, E>
where
- Dynamic<T>: DynBind<E>,
+ T: DynBind<E>,
{
type Error = ValueError<T>;
- type Output = Dynamic<T>;
+ type Output = T;
type Value = T;
type Seed = ();
fn unwrap_output(output: Self::Output) -> Self::Value {
- output.0
+ output
}
}
-impl<'lt, 'ctx: 'lt, T: 'static, Clone, E: Environment> crate::Builder<'lt, 'ctx, E> for ValueBuilder<T, Clone, E>
+impl<'src, T: 'static, Clone, E: Environment> crate::Builder<'src, E> for ValueBuilder<T, Clone, E>
where
- Dynamic<T>: DynBind<E>,
- Self: AnyTrait<'lt, 'ctx>,
+ T: DynBind<E>,
+ Self: AnyTrait<'src>,
{
fn build<'a>(self) -> Canonical<'a, Result<Self::Output, Self::Error>, E>
where
@@ -95,152 +95,82 @@ where
}
}
-impl<'lt, 'ctx: 'lt, T: 'static, Clone, E: Environment> AsVisitor<'lt, 'ctx, E> for ValueBuilder<T, Clone, E>
+impl<'src, T: 'static, Clone, E: Environment> AsVisitor<'src, E> for ValueBuilder<T, Clone, E>
where
- Self: AnyTrait<'lt, 'ctx> + DynBind<E>,
+ Self: AnyTrait<'src> + DynBind<E>,
{
- fn as_visitor<'a>(&'a mut self) -> DynVisitor<'a, 'lt, 'ctx, E> {
- DynVisitor(self)
+ fn as_visitor(&mut self) -> DynVisitor<'_, 'src, E> {
+ DynVisitor::new(self)
}
}
-impl<'lt, 'ctx: 'lt, T: 'static, E: Environment> AnyTrait<'lt, 'ctx> for ValueBuilder<T, NotCloneable, E>
+impl<'src, T: 'static, E: Environment> AnyTrait<'src> 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>,
+ Self: RequestHint<'src, E> + Value<'src, OwnedStatic<T>, E>,
{
- 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
- {
+ fn upcast_by_id_mut(
+ &mut self,
+ id: crate::any::WithLtTypeId<'src>,
+ ) -> Option<crate::any::MutAnyUnsized<'_, 'src>> {
trait_by_id!(&mut self, id, {
- type Impls = (dyn RequestHint<'ctx, E>, dyn Value<'ctx, OwnedStatic<T>, E>);
+ type Impls = (dyn RequestHint<'src, E>, dyn Value<'src, OwnedStatic<T>, E>);
});
None
}
}
-impl<'lt, 'ctx: 'lt, T: 'static + Clone, E: Environment> AnyTrait<'lt, 'ctx> for ValueBuilder<T, Cloneable, E>
+impl<'src, T: 'static + Clone, E: Environment> AnyTrait<'src> for ValueBuilder<T, Cloneable, E>
where
- Dynamic<T>: DynBind<E>,
- for<'a> Dynamic<&'a T>: DynBind<E>,
- for<'a> Dynamic<&'a OwnedStatic<T>>: DynBind<E>,
- Dynamic<OwnedStatic<T>>: DynBind<E>,
- Dynamic<BorrowedStatic<'ctx, T>>: DynBind<E>,
- for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, T>>: DynBind<E>,
- for<'a> Dynamic<TempBorrowedStatic<'a, T>>: DynBind<E>,
- for<'a> Dynamic<&'a TempBorrowedStatic<'a, T>>: DynBind<E>,
- Dynamic<BorrowedMutStatic<'ctx, T>>: DynBind<E>,
- for<'a, 'b> Dynamic<&'a BorrowedMutStatic<'b, T>>: DynBind<E>,
- for<'a> Dynamic<TempBorrowedMutStatic<'a, T>>: DynBind<E>,
- for<'a> Dynamic<&'a TempBorrowedMutStatic<'a, T>>: DynBind<E>,
+ T: DynBind<E> + IsSync<E::NeedSend>,
+ Self: Value<'src, OwnedStatic<T>, E>
+ + Value<'src, Raised<'src, 'src, BorrowedStatic<'src, i32>>, E>,
{
- 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);
+ fn upcast_by_id_mut(
+ &mut self,
+ id: crate::any::WithLtTypeId<'src>,
+ ) -> Option<crate::any::MutAnyUnsized<'_, 'src>> {
trait_by_id!(&mut self, id, {
- type Impls = (dyn RequestHint<'ctx, E>, dyn Value<'ctx, OwnedStatic<T>, E>);
+ type Impls = (
+ dyn RequestHint<'src, E>,
+ dyn Value<'src, OwnedStatic<T>, E>,
+ dyn Value<'_, Raised<'_, '_, BorrowedStatic<'_, T>>, E>,
+ dyn Value<'_, Raised<'_, '_, TempBorrowedStatic<'_, T>>, E>,
+ );
});
None
}
}
-// any_trait! {
-// impl['ctx, T][E] ValueBuilder<T, NotCloneable, E> = [
-// RequestHintProto<E>,
-// ValueProto<OwnedStatic<T>, E>,
-// ] where
-// E: Environment,
-// T: 'static,
-// Dynamic<T>: DynBind<E>,
-// for<'a> Dynamic<&'a T>: DynBind<E>,
-// Dynamic<OwnedStatic<T>>: DynBind<E>,
-// for<'a> Dynamic<&'a OwnedStatic<T>>: DynBind<E>,
-// }
-//
-// any_trait! {
-// impl['ctx, T][E] ValueBuilder<T, Cloneable, E> = [
-// RequestHintProto<E>,
-// ValueProto<OwnedStatic<T>, E>,
-// ValueProto<BorrowedStaticHrt<T>, E>,
-// ValueProto<TempBorrowedStaticHrt<T>, E>,
-// ValueProto<BorrowedMutStaticHrt<T>, E>,
-// ValueProto<TempBorrowedMutStaticHrt<T>, E>,
-// ] where
-// E: Environment,
-// T: 'static + Clone,
-// Dynamic<T>: DynBind<E>,
-// for<'a> Dynamic<&'a T>: DynBind<E>,
-// for<'a> Dynamic<&'a OwnedStatic<T>>: DynBind<E>,
-// Dynamic<OwnedStatic<T>>: DynBind<E>,
-// Dynamic<BorrowedStatic<'ctx, T>>: DynBind<E>,
-// for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, T>>: DynBind<E>,
-// for<'a> Dynamic<TempBorrowedStatic<'a, T>>: DynBind<E>,
-// for<'a> Dynamic<&'a TempBorrowedStatic<'a, T>>: DynBind<E>,
-// Dynamic<BorrowedMutStatic<'ctx, T>>: DynBind<E>,
-// for<'a, 'b> Dynamic<&'a BorrowedMutStatic<'b, T>>: DynBind<E>,
-// for<'a> Dynamic<TempBorrowedMutStatic<'a, T>>: DynBind<E>,
-// for<'a> Dynamic<&'a TempBorrowedMutStatic<'a, T>>: DynBind<E>,
-// }
-
-impl<'ctx, T: 'static, E: Environment> RequestHint<'ctx, E> for ValueBuilder<T, NotCloneable, E>
+impl<'src, T: 'static, E: Environment> RequestHint<'src, E> 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>,
+ T: DynBind<E>,
+ T: IsSync<E::NeedSend>,
{
- fn request_hint<'this: 'e, 'walker: 'e, 'lt: 'e, 'e>(
- &'this mut self,
- walker: DynWalker<'walker, 'lt, 'ctx, E>,
- ) -> Canonical<'e, VisitResult, E>
- where
- 'ctx: 'this + 'walker,
- {
+ fn request_hint<'r>(
+ &'r mut self,
+ walker: DynWalker<'r, 'src, E>,
+ ) -> Canonical<'r, VisitResult, E> {
E::value((self, walker))
.update_map((), |_, (this, walker)| {
- hint_protocol::<dyn Value<'_, OwnedStatic<T>, E>, _, _>(walker.cast(), *this, ()).cast()
- })
- .map((), |_, (_, x)| x)
- .cast()
+ hint_protocol::<dyn Value<'_, OwnedStatic<T>, E>, _, _>(walker.cast(), *this, ())
+ .cast()
+ })
+ .map((), |_, (_, x)| x)
+ .cast()
}
}
-impl<'ctx, T: 'static, E: Environment> RequestHint<'ctx, E> for ValueBuilder<T, Cloneable, E>
+impl<'src, T: 'static, E: Environment> RequestHint<'src, E> for ValueBuilder<T, Cloneable, E>
where
- T: Clone,
- Dynamic<T>: DynBind<E>,
- for<'a> Dynamic<&'a T>: DynBind<E>,
- Dynamic<OwnedStatic<T>>: DynBind<E>,
- for<'a> Dynamic<&'a OwnedStatic<T>>: DynBind<E>,
- Dynamic<BorrowedStatic<'ctx, T>>: DynBind<E>,
- for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, T>>: DynBind<E>,
- for<'a> Dynamic<TempBorrowedStatic<'a, T>>: DynBind<E>,
- for<'a> Dynamic<&'a TempBorrowedStatic<'a, T>>: DynBind<E>,
- Dynamic<BorrowedMutStatic<'ctx, T>>: DynBind<E>,
- for<'a, 'b> Dynamic<&'a BorrowedMutStatic<'b, T>>: DynBind<E>,
- for<'a> Dynamic<TempBorrowedMutStatic<'a, T>>: DynBind<E>,
- for<'a> Dynamic<&'a TempBorrowedMutStatic<'a, T>>: DynBind<E>,
+ T: Clone + DynBind<E> + IsSync<E::NeedSend>,
+ Self: AnyTrait<'src>,
{
- fn request_hint<'this: 'e, 'walker: 'e, 'lt: 'e, 'e>(
- &'this mut self,
- walker: DynWalker<'walker, 'lt, 'ctx, E>,
- ) -> Canonical<'e, VisitResult, E>
- where
- 'ctx: 'this + 'walker,
- {
+ fn request_hint<'r>(
+ &'r mut self,
+ walker: DynWalker<'r, 'src, E>,
+ ) -> Canonical<'r, VisitResult, E> {
E::value((self, walker))
.update_map((), |_, (this, walker)| {
hint_protocol::<dyn Value<'_, OwnedStatic<T>, E>, _, _>(walker.cast(), *this, ())
@@ -287,94 +217,70 @@ where
}
}
-impl<'ctx, T: 'static, Clone, E: Environment> Value<'ctx, OwnedStatic<T>, E>
+impl<'src, T: 'static, Clone, E: Environment> Value<'src, OwnedStatic<T>, E>
for ValueBuilder<T, Clone, E>
where
- Dynamic<T>: DynBind<E>,
- Dynamic<OwnedStatic<T>>: DynBind<E>,
+ T: DynBind<E>,
{
- fn visit<'this: 'value, 'value: 'e, 'e>(
- &'this mut self,
- value: type_name::Lowered<'value, 'ctx, OwnedStatic<T>>,
- ) -> Canonical<'e, VisitResult<Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<T>>>>, E>
+ fn visit<'r>(
+ &'r mut self,
+ value: type_name::Lowered<'r, 'src, OwnedStatic<T>>,
+ ) -> Canonical<'r, VisitResult<type_name::Lowered<'r, 'src, OwnedStatic<T>>>, E>
where
- type_name::Lowered<'value, 'ctx, OwnedStatic<T>>: Sized,
- Dynamic<type_name::Lowered<'value, 'ctx, OwnedStatic<T>>>: DynBind<E>,
- 'ctx: 'this + 'value,
+ type_name::Lowered<'r, 'src, OwnedStatic<T>>: Sized + DynBind<E>,
{
- self.value = Some(Dynamic(value.0));
+ self.value = Some(value.0);
E::value(Flow::Done.into()).cast()
}
}
-impl<'ctx, T: 'static, E: Environment>
- Value<'ctx, type_name::Raised<'static, 'ctx, BorrowedStatic<'ctx, T>>, E>
+impl<'src, T: 'static, E: Environment>
+ Value<'src, type_name::Raised<'src, 'src, BorrowedStatic<'src, T>>, E>
for ValueBuilder<T, Cloneable, E>
where
- T: Clone,
- Dynamic<T>: DynBind<E>,
- Dynamic<BorrowedStatic<'ctx, T>>: DynBind<E>,
+ T: DynBind<E> + Clone,
{
- fn visit<'this: 'value, 'value: 'e, 'e>(
- &'this mut self,
- value: type_name::Lowered<
- 'value,
- 'ctx,
- type_name::Raised<'static, 'ctx, BorrowedStatic<'ctx, T>>,
- >,
+ fn visit<'r>(
+ &'r mut self,
+ value: type_name::Lowered<'r, 'src, type_name::Raised<'r, 'src, BorrowedStatic<'src, T>>>,
) -> Canonical<
- 'e,
+ 'r,
VisitResult<
- Dynamic<
- type_name::Lowered<
- 'value,
- 'ctx,
- type_name::Raised<'static, 'ctx, BorrowedStatic<'ctx, T>>,
- >,
- >,
+ type_name::Lowered<'r, 'src, type_name::Raised<'r, 'src, BorrowedStatic<'src, T>>>,
>,
E,
>
where
- type_name::Lowered<'value, 'ctx, type_name::Raised<'static, 'ctx, BorrowedStatic<'ctx, T>>>:
- Sized,
- Dynamic<
- type_name::Lowered<
- 'value,
- 'ctx,
- type_name::Raised<'static, 'ctx, BorrowedStatic<'ctx, T>>,
- >,
- >: DynBind<E>,
- 'ctx: 'this + 'value,
+ type_name::Lowered<'r, 'src, type_name::Raised<'r, 'src, BorrowedStatic<'src, T>>>:
+ Sized + DynBind<E>,
{
- self.value = Some(Dynamic(value.0.clone()));
+ self.value = Some(value.0.clone());
+
+ E::value(Flow::Done.into()).cast()
+ }
+}
+
+impl<'ctx, T: 'static, E: Environment>
+ Value<'ctx, type_name::Raised<'ctx, 'ctx, TempBorrowedStatic<'ctx, T>>, E>
+ for ValueBuilder<T, Cloneable, E>
+where
+ T: Clone + DynBind<E>,
+{
+ fn visit<'a>(
+ &'a mut self,
+ TempBorrowedStatic(value): TempBorrowedStatic<'a, T>,
+ ) -> Canonical<'a, VisitResult<TempBorrowedStatic<'a, T>>, E>
+ where
+ 'ctx: 'a,
+ TempBorrowedStatic<'a, T>: DynBind<E>,
+ {
+ self.value = Some(value.clone());
E::value(Flow::Done.into()).cast()
}
}
-// impl<'ctx, T: 'static, E: Environment>
-// Value<'ctx, type_name::Raised<'static, 'ctx, TempBorrowedStatic<'static, T>>, E>
-// for ValueBuilder<T, Cloneable, E>
-// where
-// T: Clone,
-// Dynamic<T>: DynBind<E>,
-// for<'a> Dynamic<TempBorrowedStatic<'a, T>>: DynBind<E>,
-// {
-// fn visit<'a>(
-// &'a mut self,
-// TempBorrowedStatic(value): TempBorrowedStatic<'a, T>,
-// ) -> Canonical<'a, VisitResult<Dynamic<TempBorrowedStatic<'a, T>>>, E>
-// where
-// 'ctx: 'a,
-// {
-// self.value = Some(Dynamic(value.clone()));
-//
-// E::value(Flow::Done.into()).cast()
-// }
-// }
-//
// impl<'ctx, T: 'static, E: Environment> Value<'ctx, BorrowedMutStatic<'ctx, T>, E>
// for ValueBuilder<T, Cloneable, E>
// where