Diffstat (limited to 'src/walk/walkers/core/int.rs')
-rw-r--r--src/walk/walkers/core/int.rs33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/walk/walkers/core/int.rs b/src/walk/walkers/core/int.rs
index 97dc54d..2df49ea 100644
--- a/src/walk/walkers/core/int.rs
+++ b/src/walk/walkers/core/int.rs
@@ -1,7 +1,9 @@
+use effectful::environment::{DynBind, Environment, NativeForm};
+use effectful::forward_send_sync;
+
use crate::{
any::OwnedStatic,
any_trait,
- effect::{Effect, EffectExt as _, Effective as _, EffectiveExt as _, ErasedEffective, Ss},
hkt::Marker,
never::Never,
protocol::{
@@ -19,12 +21,13 @@ pub struct IntegerWalker<T, E> {
_marker: Marker<E>,
}
+forward_send_sync!({T} {} {E} IntegerWalker<T, E>);
+
pub trait Integer:
'static
+ Copy
+ core::fmt::Debug
+ core::fmt::Display
- + Ss
+ TryInto<u8>
+ TryInto<u16>
+ TryInto<u32>
@@ -57,6 +60,8 @@ pub struct IntegerWalkerError<T> {
value: T,
}
+forward_send_sync!({T} {} IntegerWalkerError<T>);
+
impl<T: Integer> ::core::fmt::Debug for IntegerWalkerError<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("IntegerWalkerError")
@@ -73,15 +78,18 @@ impl<T: Integer> ::core::fmt::Display for IntegerWalkerError<T> {
}
}
-impl<'ctx, T: Integer, E: Effect> Walker<'ctx, E> for IntegerWalker<T, E> {
+impl<'ctx, T: Integer, E: Environment> Walker<'ctx, E> for IntegerWalker<T, E>
+where
+ T: DynBind<E>
+{
type Error = IntegerWalkerError<T>;
type Output = T;
fn walk<'visitor: 'effect, 'effect>(
self,
- visitor: DynVisitor<'visitor, 'ctx>,
- ) -> ErasedEffective<'effect, Result<Self::Output, Self::Error>, E>
+ visitor: DynVisitor<'visitor, 'ctx, E>,
+ ) -> NativeForm<'effect, Result<Self::Output, Self::Error>, E>
where
Self: 'effect,
{
@@ -213,7 +221,6 @@ impl<T> Integer for T where
+ Copy
+ core::fmt::Debug
+ core::fmt::Display
- + Ss
+ TryInto<u8>
+ TryInto<u16>
+ TryInto<u32>
@@ -230,7 +237,7 @@ impl<T> Integer for T where
}
any_trait! {
- impl['ctx, T, E] IntegerWalker<T, E> = [
+ impl['ctx, T][E] IntegerWalker<T, E> = [
HintProto<ValueProto<OwnedStatic<i8>, E>>,
HintProto<ValueProto<OwnedStatic<i16>, E>>,
HintProto<ValueProto<OwnedStatic<i32>, E>>,
@@ -242,20 +249,22 @@ any_trait! {
HintProto<ValueProto<OwnedStatic<u64>, E>>,
HintProto<ValueProto<OwnedStatic<u128>, E>>,
] where
- T: Integer,
- E: Effect
+ T: DynBind<E> + Integer,
+ E: Environment
}
macro_rules! impl_hints {
($($type:ty),* $(,)?) => {
- $(impl<'ctx, T: Integer, E: Effect> Hint<'ctx, ValueProto<OwnedStatic<$type>, E>>
+ $(impl<'ctx, T: Integer, E: Environment> Hint<'ctx, ValueProto<OwnedStatic<$type>, E>>
for IntegerWalker<T, E>
+ where
+ T: DynBind<E>,
{
fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
&'this mut self,
visitor: DynVisitorWith<'visitor, 'ctx, ValueProto<OwnedStatic<$type>, E>>,
_hint: MetaHint<'hint, 'ctx, ValueProto<OwnedStatic<$type>, E>>,
- ) -> ErasedEffective<'e, crate::protocol::visitor::VisitResult, E>
+ ) -> NativeForm<'e, crate::protocol::visitor::VisitResult, E>
where
'ctx: 'this + 'visitor + 'hint + 'e,
{
@@ -270,7 +279,7 @@ macro_rules! impl_hints {
fn known<'a>(
&'a mut self,
_hint: &'a MetaHint<'a, 'ctx, ValueProto<OwnedStatic<$type>, E>>,
- ) -> ErasedEffective<'a, Result<MetaKnown<'a, 'ctx, ValueProto<OwnedStatic<$type>, E>>, ()>, E>
+ ) -> NativeForm<'a, Result<MetaKnown<'a, 'ctx, ValueProto<OwnedStatic<$type>, E>>, ()>, E>
{
E::ready(Ok(ValueKnown { preview: None }))
}