#[fp_macros::document_module]
mod inner {
use {
crate::{
classes::*,
kinds::*,
},
fp_macros::*,
};
#[kind(type Of<'a, A: 'a>: 'a;)]
pub trait RefWitherable: RefFilterable + RefTraversable {
#[document_signature]
#[document_type_parameters(
"The lifetime of the elements.",
"The brand of the cloneable function wrapper.",
"The applicative context.",
"The type of the input elements.",
"The error type.",
"The success type."
)]
#[document_parameters(
"The function to apply to each element reference.",
"The structure to partition."
)]
#[document_returns("The partitioned structure in the applicative context.")]
#[document_examples]
fn ref_wilt<'a, FnBrand, M: Applicative, A: 'a + Clone, E: 'a + Clone, O: 'a + Clone>(
func: impl Fn(&A) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Result<O, E>>)
+ 'a,
ta: &Apply!(<Self as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
(
Apply!(<Self as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, E>),
Apply!(<Self as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, O>),
),
>)
where
FnBrand: LiftFn + 'a,
Apply!(<Self 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, {
M::map(
|res| Self::separate::<E, O>(res),
Self::ref_traverse::<FnBrand, A, Result<O, E>, M>(func, ta),
)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the elements.",
"The brand of the cloneable function wrapper.",
"The applicative context.",
"The type of the input elements.",
"The type of the output elements."
)]
#[document_parameters(
"The function to apply to each element reference.",
"The structure to filter."
)]
#[document_returns("The filtered structure in the applicative context.")]
#[document_examples]
fn ref_wither<'a, FnBrand, M: Applicative, A: 'a + Clone, B: 'a + Clone>(
func: impl Fn(&A) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Option<B>>) + 'a,
ta: &Apply!(<Self as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<
'a,
Apply!(<Self as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
>)
where
FnBrand: LiftFn + 'a,
Apply!(<Self 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, {
M::map(
|opt| Self::compact(opt),
Self::ref_traverse::<FnBrand, A, Option<B>, M>(func, ta),
)
}
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the elements.",
"The brand of the structure.",
"The brand of the cloneable function wrapper.",
"The applicative context.",
"The type of the input elements.",
"The error type.",
"The success type."
)]
#[document_parameters(
"The function to apply to each element reference.",
"The structure to partition."
)]
#[document_returns("The partitioned structure in the applicative context.")]
#[document_examples]
pub fn ref_wilt<
'a,
Brand: RefWitherable,
FnBrand,
M: Applicative,
A: 'a + Clone,
E: 'a + Clone,
O: 'a + Clone,
>(
func: impl Fn(&A) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Result<O, E>>) + 'a,
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>),
),
>)
where
FnBrand: LiftFn + '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, {
Brand::ref_wilt::<FnBrand, M, A, E, O>(func, ta)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the elements.",
"The brand of the structure.",
"The brand of the cloneable function wrapper.",
"The applicative context.",
"The type of the input elements.",
"The type of the output elements."
)]
#[document_parameters(
"The function to apply to each element reference.",
"The structure to filter."
)]
#[document_returns("The filtered structure in the applicative context.")]
#[document_examples]
pub fn ref_wither<
'a,
Brand: RefWitherable,
FnBrand,
M: Applicative,
A: 'a + Clone,
B: 'a + Clone,
>(
func: impl Fn(&A) -> Apply!(<M as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Option<B>>) + 'a,
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>),
>)
where
FnBrand: LiftFn + '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, {
Brand::ref_wither::<FnBrand, M, A, B>(func, ta)
}
}
pub use inner::*;