Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 55 |
1 files changed, 30 insertions, 25 deletions
@@ -10,7 +10,7 @@ extern crate alloc; pub mod any; mod build; mod doc_macro; -pub mod effect; +// pub mod effect; pub mod hkt; pub mod macros; pub mod protocol; @@ -21,13 +21,16 @@ mod walk; use core::ops::ControlFlow; pub use build::*; -use effect::ConvertShort; +use effectful::{is_send_sync, short::ConvertShort}; +// use effect::ConvertShort; pub use transform::*; pub use walk::*; use symbol::Symbol; pub mod never { + use effectful::is_send_sync; + mod sealed { pub trait Extract { type Never; @@ -39,7 +42,11 @@ pub mod never { } /// Test - pub type Never = <fn() -> ! as sealed::Extract>::Never; + // pub type Never = <fn() -> ! as sealed::Extract>::Never; + #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub enum Never {} + + is_send_sync!(Never); } pub const TAG_TYPE_NAME: Symbol = Symbol::new("Type Name"); @@ -66,6 +73,8 @@ pub enum Status { Err, } +is_send_sync!(Status, Flow); + #[derive(Clone, Copy, PartialEq, Debug)] #[must_use] pub enum Flow { @@ -76,15 +85,6 @@ pub enum Flow { Done, } -impl ConvertShort<ControlFlow<Flow>> for Option<never::Never> { - fn convert_short(short: Self) -> ControlFlow<Flow> { - match short { - None => ControlFlow::Break(Flow::Done), - Some(_) => unreachable!(), - } - } -} - impl Flow { pub fn to_status(self) -> Status { match self { @@ -124,11 +124,14 @@ macro_rules! Walk { ),* $(,)?} } => { const _: () = { - impl<'ctx, M: 'ctx, E: $crate::effect::Effect> $crate::Walk<'ctx, M, E> for &'ctx $name { + impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::Walk<'ctx, M, E> for &'ctx $name + where + $name: effectful::bound::IsSync<E::NeedSend> + effectful::environment::DynBind<E> + { type Walker = $crate::walkers::core::r#struct::StructWalker<'ctx, Info, $crate::any::StaticType, M, E>; - fn into_walker<'e>(self) -> $crate::effect::ErasedEffective<'e, Self::Walker, E> { - E::ready($crate::walkers::core::r#struct::StructWalker::new(self)) + fn into_walker<'e>(self) -> effectful::environment::NativeForm<'e, Self::Walker, E> { + E::value($crate::walkers::core::r#struct::StructWalker::new(self)).cast() } } @@ -140,20 +143,26 @@ macro_rules! Walk { $vis enum Info {} #[allow(non_camel_case_types, unused)] - enum FieldErrorKind<'ctx, M, E: $crate::effect::Effect> {$( + enum FieldErrorKind<'ctx, M, E: effectful::environment::Environment> {$( $field($crate::walkers::core::key_value::KeyValueError<$crate::never::Never, <<&'ctx $type as $crate::Walk<'ctx, M, E>>::Walker as $crate::Walker<'ctx, E>>::Error>) ),*} #[allow(unused)] - $vis struct FieldError<'ctx, M, E: $crate::effect::Effect>(FieldErrorKind<'ctx, M, E>); + $vis struct FieldError<'ctx, M, E: effectful::environment::Environment>(FieldErrorKind<'ctx, M, E>); + + unsafe impl<'ctx, M, E: effectful::environment::Environment> effectful::bound::IsSend<E::NeedSend> for FieldError<'ctx, M, E> {} + unsafe impl<'ctx, M, E: effectful::environment::Environment> effectful::bound::IsSync<E::NeedSync> for FieldError<'ctx, M, E> {} - impl<'ctx, M, E: $crate::effect::Effect> ::core::fmt::Debug for FieldError<'ctx, M, E> { + impl<'ctx, M, E: effectful::environment::Environment> ::core::fmt::Debug for FieldError<'ctx, M, E> { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { todo!() } } - impl<'ctx, M: 'ctx, E: $crate::effect::Effect> $crate::walkers::core::r#struct::StructTypeInfo<'ctx, M, E> for Info { + impl<'ctx, M: 'ctx, E: effectful::environment::Environment> $crate::walkers::core::r#struct::StructTypeInfo<'ctx, M, E> for Info + where + $name: effectful::bound::IsSync<E::NeedSend> + effectful::environment::DynBind<E> + { const NAME: &'static str = stringify!($name); const FIELDS: &'static [&'static str] = &[$(stringify!($field)),*]; @@ -165,16 +174,14 @@ macro_rules! Walk { fn walk_field<'a>( index: usize, value: &'ctx Self::T, - visitor: $crate::protocol::DynVisitor<'a, 'ctx>, - ) -> $crate::effect::ErasedEffective<'a, Result<$crate::Flow, Self::FieldError>, E> { + visitor: $crate::protocol::DynVisitor<'a, 'ctx, E>, + ) -> effectful::environment::NativeForm<'a, Result<$crate::Flow, Self::FieldError>, E> { mod fields { enum Fields {$($field),*} $(pub const $field: usize = Fields::$field as usize;)* } - use $crate::effect::EffectiveExt; - match index { $(fields::$field => { let key_walker = $crate::walkers::core::value::ValueWalker::new(stringify!($field)); @@ -275,8 +282,6 @@ pub mod demo { #[test] fn demo() { - use crate::effect::BlockOn as _; - assert_eq!(ident(X { a: true, b: false }), Y { a: true, b: false }); crate::effect::blocking::Spin::block_on(async { |