Diffstat (limited to 'src/effect/blocking.rs')
-rw-r--r--src/effect/blocking.rs98
1 files changed, 51 insertions, 47 deletions
diff --git a/src/effect/blocking.rs b/src/effect/blocking.rs
index 5913dda..11c3b7d 100644
--- a/src/effect/blocking.rs
+++ b/src/effect/blocking.rs
@@ -24,29 +24,29 @@ impl<T, B> Value<T, B> {
}
}
-impl<'lt, T: Ss, B: BlockOn, O> ErasedForLt<'lt, T, Blocking<B>, &'lt (T, O), O> for Value<T, B> {
- type T = Value<T, B>;
+impl<'lt, T: Ss, B: BlockOn, O> Erased::ForLt<'lt, T, Blocking<B>, &'lt (T, O)> for Value<T, B> {
+ type Effective = Value<T, B>;
}
-impl<T: Ss, B: BlockOn> ErasedHrt<T, Blocking<B>> for Value<T, B> {
- type T<O> = Self;
+impl<T: Ss, B: BlockOn> Erased::Hkt<T, Blocking<B>> for Value<T, B> {
+ type Hrt<O> = Self;
}
impl<B: BlockOn> Effect for Blocking<B> {
type Erased<T: Ss> = Value<T, B>;
- type Ready<'a, T: Ss + 'a> = Value<T, B>;
+ // type Ready<'a, T: Ss + 'a> = Value<T, B>;
- fn ready<'a, T: Ss + 'a>(value: T) -> Self::Ready<'a, T> {
+ fn ready<'a, T: Ss + 'a>(value: T) -> ErasedEffective<'a, T, Self> {
Value(value, Default::default())
}
- type FromFuture<'a, F: Ss + 'a> = Value<F::Output, B>
- where
- F: Future,
- F::Output: Ss + 'a;
+ // type FromFuture<'a, F: Ss + 'a> = Value<F::Output, B>
+ // where
+ // F: Future,
+ // F::Output: Ss + 'a;
- fn from_future<'a, F: Ss + 'a>(future: F) -> Self::FromFuture<'a, F>
+ fn from_future<'a, F: Ss + 'a>(future: F) -> ErasedEffective<'a, F::Output, Self>
where
F: Future,
F::Output: Ss + 'a,
@@ -70,16 +70,18 @@ impl<'lt, U: Ss + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
core::future::ready(self.0)
}
- type Loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>
- = Value<(U, T), B>
- where
- F: for<'b> FnMut(&'b mut Self::Output) -> ErasedEffective<'b, ControlFlow<T>, Self::Effect>,
- 'lt: 'a;
+ // type Loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>
+ // = Value<(U, T), B>
+ // where
+ // F: for<'b> FnMut(&'b mut Self::Output) -> ErasedEffective<'b, ControlFlow<T>, Self::Effect>,
+ // 'lt: 'a;
- fn r#loop<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>(self, mut cb: F) -> Self::Loop<'ctx, 'a, T, F>
+ fn r#loop<'ctx: 'lt, 'wrap, T: Ss, F: Ss>(
+ self,
+ mut cb: F,
+ ) -> ErasedEffective<'wrap, (Self::Output, T), Self::Effect>
where
F: for<'b> FnMut(&'b mut Self::Output) -> ErasedEffective<'b, ControlFlow<T>, Self::Effect>,
- 'lt: 'a,
{
let mut this = self.0;
@@ -90,50 +92,52 @@ impl<'lt, U: Ss + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> {
}
}
- type Map<'a, T: Ss + 'a, F: Ss + 'a> = Value<T, B>
- where
- F: FnOnce(Self::Output) -> T,
- 'lt: 'a;
+ // type Map<'a, T: Ss + 'a, F: Ss + 'a> = Value<T, B>
+ // where
+ // F: FnOnce(Self::Output) -> T,
+ // 'lt: 'a;
- fn map<'a, T: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::Map<'a, T, F>
+ fn map<'wrap, T: Ss, F: Ss>(self, cb: F) -> ErasedEffective<'wrap, T, Self::Effect>
where
F: FnOnce(Self::Output) -> T,
- 'lt: 'a,
+ 'lt: 'wrap,
{
Value(cb(self.0), Default::default())
}
- type Then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a> = Value<T, B>
- where
- F: FnOnce(Self::Output) -> V,
- V: Effective<'a, Output = T, Effect = Self::Effect>,
- 'lt: 'a;
+ // type Then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a> = Value<T, B>
+ // where
+ // F: FnOnce(Self::Output) -> V,
+ // V: Effective<'a, Output = T, Effect = Self::Effect>,
+ // 'lt: 'a;
- fn then<'a, T: Ss + 'a, V: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::Then<'a, T, V, F>
+ fn then<'a, T: Ss, F: Ss>(self, cb: F) -> ErasedEffective<'a, T, Self::Effect>
where
- F: FnOnce(Self::Output) -> V,
- V: Effective<'a, Output = T, Effect = Self::Effect>,
+ F: FnOnce(Self::Output) -> ErasedEffective<'a, T, Self::Effect>,
'lt: 'a,
{
cb(self.0).into_erased::<()>()
}
- type AsCtx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a> = Value<(U, T), B>
- where
- F: for<'b> FnOnce(&'b mut Self::Output) -> ErasedEffective<'b, T, Self::Effect, (&'b mut Self::Output, &'ctx ())>,
- 'lt: 'a;
-
- fn as_ctx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a>(self, cb: F) -> Self::AsCtx<'ctx, 'a, T, F>
- where
- F: for<'b> FnOnce(
- &'b mut Self::Output,
- )
- -> ErasedEffective<'b, T, Self::Effect, (&'b mut Self::Output, &'ctx ())>,
- 'lt: 'a,
+ // type AsCtx<'ctx: 'a, 'a, T: Ss + 'a, F: Ss + 'a> = Value<(U, T), B>
+ // where
+ // F: for<'b> FnOnce(&'b mut Self::Output) -> ErasedEffective<'b, T, Self::Effect, (&'b mut Self::Output, &'ctx ())>,
+ // 'lt: 'a;
+
+ fn as_ctx<'ctx: 'lt, 'wrap, T: Ss, S: Ss, C: Ss, K: Ss, F: Ss, A: Ss, R: Ss>(
+ self,
+ split: S,
+ cb: F,
+ after: A,
+ ) -> ErasedEffective<'wrap, R, Self::Effect>
+ where
+ S: FnOnce(Self::Output) -> (C, K),
+ F: for<'b> FnOnce(&'b mut C, K) -> ErasedEffective<'b, T, Self::Effect>,
+ A: FnOnce(C, T) -> R,
{
- let mut this = self.0;
- let result = cb(&mut this).0;
- Value((this, result), Default::default())
+ let (mut this, owned) = split(self.0);
+ let result = cb(&mut this, owned).0;
+ Value(after(this, result), Default::default())
}
}