#[fp_macros::document_module]
pub(crate) mod inner {
use {
crate::{
classes::{
Applicative,
LiftFn,
RefWitherable,
Witherable,
},
dispatch::{
Ref,
Val,
},
kinds::*,
},
fp_macros::*,
};
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use.",
"The brand of the witherable structure.",
"The applicative functor brand for the computation.",
"The type of the elements in the input structure.",
"The error type.",
"The success type.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically. Either [`Val`](crate::dispatch::Val) or [`Ref`](crate::dispatch::Ref)."
)]
#[document_parameters("The closure implementing this dispatch.")]
pub trait WiltDispatch<
'a,
FnBrand,
Brand: Kind_cdc7cd43dac7585f,
M: Kind_cdc7cd43dac7585f,
A: 'a,
E: 'a,
O: 'a,
FA,
Marker,
> {
#[document_signature]
#[document_parameters("The structure to partition.")]
#[document_returns("The partitioned result in the applicative context.")]
#[document_examples]
fn dispatch(
self,
ta: FA,
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
(
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, E>),
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, O>),
),
>);
}
#[document_type_parameters(
"The lifetime of the values.",
"The cloneable function brand (unused by Val path).",
"The brand of the witherable structure.",
"The applicative functor brand.",
"The type of the elements in the input structure.",
"The error type.",
"The success type.",
"The closure type."
)]
#[document_parameters("The closure that takes owned values.")]
impl<'a, FnBrand, Brand, M, A, E, O, Func>
WiltDispatch<
'a,
FnBrand,
Brand,
M,
A,
E,
O,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
Val,
> for Func
where
Brand: Witherable,
A: 'a + Clone,
E: 'a + Clone,
O: 'a + Clone,
M: Applicative,
Func: Fn(A) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Result<O, E>>) + 'a,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Result<O, E>>): Clone,
Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Result<O, E>>): Clone,
{
#[document_signature]
#[document_parameters("The structure to partition.")]
#[document_returns("The partitioned result in the applicative context.")]
#[document_examples]
fn dispatch(
self,
ta: Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
(
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, E>),
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, O>),
),
>) {
Brand::wilt::<M, A, E, O>(self, ta)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The borrow lifetime.",
"The cloneable function brand.",
"The brand of the witherable structure.",
"The applicative functor brand.",
"The type of the elements in the input structure.",
"The error type.",
"The success type.",
"The closure type."
)]
#[document_parameters("The closure that takes references.")]
impl<'a, 'b, FnBrand, Brand, M, A, E, O, Func>
WiltDispatch<
'a,
FnBrand,
Brand,
M,
A,
E,
O,
&'b Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
Ref,
> for Func
where
Brand: RefWitherable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
E: 'a + Clone,
O: 'a + Clone,
M: Applicative,
Func: Fn(&A) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Result<O, E>>) + 'a,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Result<O, E>>): Clone,
Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Result<O, E>>): Clone,
{
#[document_signature]
#[document_parameters("A reference to the structure to partition.")]
#[document_returns("The partitioned result in the applicative context.")]
#[document_examples]
fn dispatch(
self,
ta: &'b Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
(
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, E>),
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, O>),
),
>) {
Brand::ref_wilt::<FnBrand, M, A, E, O>(self, ta)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use.",
"The brand of the witherable structure.",
"The applicative functor brand for the computation.",
"The type of the elements in the input structure.",
"The type of the elements in the output structure.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically. Either [`Val`](crate::dispatch::Val) or [`Ref`](crate::dispatch::Ref)."
)]
#[document_parameters("The closure implementing this dispatch.")]
pub trait WitherDispatch<
'a,
FnBrand,
Brand: Kind_cdc7cd43dac7585f,
M: Kind_cdc7cd43dac7585f,
A: 'a,
B: 'a,
FA,
Marker,
> {
#[document_signature]
#[document_parameters("The structure to filter.")]
#[document_returns("The filtered result in the applicative context.")]
#[document_examples]
fn dispatch(
self,
ta: FA,
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
>);
}
#[document_type_parameters(
"The lifetime of the values.",
"The cloneable function brand (unused by Val path).",
"The brand of the witherable structure.",
"The applicative functor brand.",
"The type of the elements in the input structure.",
"The type of the elements in the output structure.",
"The closure type."
)]
#[document_parameters("The closure that takes owned values.")]
impl<'a, FnBrand, Brand, M, A, B, Func>
WitherDispatch<
'a,
FnBrand,
Brand,
M,
A,
B,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
Val,
> for Func
where
Brand: Witherable,
A: 'a + Clone,
B: 'a + Clone,
M: Applicative,
Func: Fn(A) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Option<B>>) + 'a,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Option<B>>): Clone,
Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Option<B>>): Clone,
{
#[document_signature]
#[document_parameters("The structure to filter.")]
#[document_returns("The filtered result in the applicative context.")]
#[document_examples]
fn dispatch(
self,
ta: Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
>) {
Brand::wither::<M, A, B>(self, ta)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The borrow lifetime.",
"The cloneable function brand.",
"The brand of the witherable structure.",
"The applicative functor brand.",
"The type of the elements in the input structure.",
"The type of the elements in the output structure.",
"The closure type."
)]
#[document_parameters("The closure that takes references.")]
impl<'a, 'b, FnBrand, Brand, M, A, B, Func>
WitherDispatch<
'a,
FnBrand,
Brand,
M,
A,
B,
&'b Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
Ref,
> for Func
where
Brand: RefWitherable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
M: Applicative,
Func: Fn(&A) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Option<B>>) + 'a,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Option<B>>): Clone,
Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Option<B>>): Clone,
{
#[document_signature]
#[document_parameters("A reference to the structure to filter.")]
#[document_returns("The filtered result in the applicative context.")]
#[document_examples]
fn dispatch(
self,
ta: &'b Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
>) {
Brand::ref_wither::<FnBrand, M, A, B>(self, ta)
}
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use (must be specified explicitly).",
"The container type (owned or borrowed). Brand is inferred from this.",
"The applicative functor brand (must be specified explicitly).",
"The type of the elements in the input structure.",
"The error type.",
"The success type.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"The function to apply to each element, returning a Result in an applicative context.",
"The witherable structure (owned for Val, borrowed for Ref)."
)]
#[document_returns("The partitioned structure wrapped in the applicative context.")]
#[document_examples]
pub fn wilt<'a, FnBrand, FA, M: Kind_cdc7cd43dac7585f, A: 'a, E: 'a, O: 'a, Marker>(
func: impl WiltDispatch<
'a,
FnBrand,
<FA as InferableBrand_cdc7cd43dac7585f>::Brand,
M,
A,
E,
O,
FA,
Marker,
>,
ta: FA,
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
(
Apply!(<<FA as InferableBrand!(type Of<'a, A: 'a>: 'a;)>::Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, E>),
Apply!(<<FA as InferableBrand!(type Of<'a, A: 'a>: 'a;)>::Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, O>),
),
>)
where
FA: InferableBrand_cdc7cd43dac7585f, {
func.dispatch(ta)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use (must be specified explicitly).",
"The container type (owned or borrowed). Brand is inferred from this.",
"The applicative functor brand (must be specified explicitly).",
"The type of the elements in the input structure.",
"The type of the elements in the output structure.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"The function to apply to each element, returning an Option in an applicative context.",
"The witherable structure (owned for Val, borrowed for Ref)."
)]
#[document_returns("The filtered structure wrapped in the applicative context.")]
#[document_examples]
pub fn wither<'a, FnBrand, FA, M: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, Marker>(
func: impl WitherDispatch<
'a,
FnBrand,
<FA as InferableBrand_cdc7cd43dac7585f>::Brand,
M,
A,
B,
FA,
Marker,
>,
ta: FA,
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
Apply!(<<FA as InferableBrand!(type Of<'a, A: 'a>: 'a;)>::Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
>)
where
FA: InferableBrand_cdc7cd43dac7585f, {
func.dispatch(ta)
}
pub mod explicit {
use super::*;
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use.",
"The brand of the witherable structure.",
"The applicative functor brand for the computation.",
"The type of the elements in the input structure.",
"The error type.",
"The success type.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"The function to apply to each element, returning a Result in an applicative context.",
"The witherable structure (owned for Val, borrowed for Ref)."
)]
#[document_returns("The partitioned structure wrapped in the applicative context.")]
#[document_examples]
pub fn wilt<
'a,
FnBrand,
Brand: Kind_cdc7cd43dac7585f,
M: Kind_cdc7cd43dac7585f,
A: 'a,
E: 'a,
O: 'a,
FA,
Marker,
>(
func: impl WiltDispatch<'a, FnBrand, Brand, M, A, E, O, FA, Marker>,
ta: FA,
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
(
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, E>),
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, O>),
),
>) {
func.dispatch(ta)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use.",
"The brand of the witherable structure.",
"The applicative functor brand for the computation.",
"The type of the elements in the input structure.",
"The type of the elements in the output structure.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"The function to apply to each element, returning an Option in an applicative context.",
"The witherable structure (owned for Val, borrowed for Ref)."
)]
#[document_returns("The filtered structure wrapped in the applicative context.")]
#[document_examples]
pub fn wither<
'a,
FnBrand,
Brand: Kind_cdc7cd43dac7585f,
M: Kind_cdc7cd43dac7585f,
A: 'a,
B: 'a,
FA,
Marker,
>(
func: impl WitherDispatch<'a, FnBrand, Brand, M, A, B, FA, Marker>,
ta: FA,
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
>) {
func.dispatch(ta)
}
}
}
pub use inner::*;