#[fp_macros::document_module]
pub(crate) mod inner {
use {
crate::{
classes::{
Bifoldable,
LiftFn,
Monoid,
RefBifoldable,
},
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 bifoldable structure.",
"The type of the first-position elements.",
"The type of the second-position elements.",
"The type of the accumulator.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters("The closure tuple implementing this dispatch.")]
pub trait BiFoldLeftDispatch<
'a,
FnBrand,
Brand: Kind_266801a817966495,
A: 'a,
B: 'a,
C: 'a,
FA,
Marker,
> {
#[document_signature]
#[document_parameters("The initial accumulator value.", "The structure to fold.")]
#[document_returns("The final accumulator value.")]
#[document_examples]
fn dispatch(
self,
z: C,
fa: FA,
) -> C;
}
#[document_type_parameters(
"The lifetime.",
"The cloneable function brand.",
"The bifoldable brand.",
"The first element type.",
"The second element type.",
"The accumulator type.",
"The first closure type.",
"The second closure type."
)]
#[document_parameters("The closure tuple.")]
impl<'a, FnBrand, Brand, A, B, C, F, G>
BiFoldLeftDispatch<
'a,
FnBrand,
Brand,
A,
B,
C,
Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
Val,
> for (F, G)
where
Brand: Bifoldable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
C: 'a,
F: Fn(C, A) -> C + 'a,
G: Fn(C, B) -> C + 'a,
{
#[document_signature]
#[document_parameters("The initial accumulator value.", "The structure to fold.")]
#[document_returns("The final accumulator value.")]
#[document_examples]
fn dispatch(
self,
z: C,
fa: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
) -> C {
Brand::bi_fold_left::<FnBrand, A, B, C>(self.0, self.1, z, fa)
}
}
#[document_type_parameters(
"The lifetime.",
"The borrow lifetime.",
"The cloneable function brand.",
"The bifoldable brand.",
"The first element type.",
"The second element type.",
"The accumulator type.",
"The first closure type.",
"The second closure type."
)]
#[document_parameters("The closure tuple.")]
impl<'a, 'b, FnBrand, Brand, A, B, C, F, G>
BiFoldLeftDispatch<
'a,
FnBrand,
Brand,
A,
B,
C,
&'b Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
Ref,
> for (F, G)
where
Brand: RefBifoldable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
C: 'a,
F: Fn(C, &A) -> C + 'a,
G: Fn(C, &B) -> C + 'a,
{
#[document_signature]
#[document_parameters(
"The initial accumulator value.",
"A reference to the structure to fold."
)]
#[document_returns("The final accumulator value.")]
#[document_examples]
fn dispatch(
self,
z: C,
fa: &'b Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
) -> C {
Brand::ref_bi_fold_left::<FnBrand, A, B, C>(self.0, self.1, z, fa)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use.",
"The brand of the bifoldable structure.",
"The type of the first-position elements.",
"The type of the second-position elements.",
"The type of the accumulator.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters("The closure tuple implementing this dispatch.")]
pub trait BiFoldRightDispatch<
'a,
FnBrand,
Brand: Kind_266801a817966495,
A: 'a,
B: 'a,
C: 'a,
FA,
Marker,
> {
#[document_signature]
#[document_parameters("The initial accumulator value.", "The structure to fold.")]
#[document_returns("The final accumulator value.")]
#[document_examples]
fn dispatch(
self,
z: C,
fa: FA,
) -> C;
}
#[document_type_parameters(
"The lifetime.",
"The cloneable function brand.",
"The bifoldable brand.",
"The first element type.",
"The second element type.",
"The accumulator type.",
"The first closure type.",
"The second closure type."
)]
#[document_parameters("The closure tuple.")]
impl<'a, FnBrand, Brand, A, B, C, F, G>
BiFoldRightDispatch<
'a,
FnBrand,
Brand,
A,
B,
C,
Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
Val,
> for (F, G)
where
Brand: Bifoldable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
C: 'a,
F: Fn(A, C) -> C + 'a,
G: Fn(B, C) -> C + 'a,
{
#[document_signature]
#[document_parameters("The initial accumulator value.", "The structure to fold.")]
#[document_returns("The final accumulator value.")]
#[document_examples]
fn dispatch(
self,
z: C,
fa: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
) -> C {
Brand::bi_fold_right::<FnBrand, A, B, C>(self.0, self.1, z, fa)
}
}
#[document_type_parameters(
"The lifetime.",
"The borrow lifetime.",
"The cloneable function brand.",
"The bifoldable brand.",
"The first element type.",
"The second element type.",
"The accumulator type.",
"The first closure type.",
"The second closure type."
)]
#[document_parameters("The closure tuple.")]
impl<'a, 'b, FnBrand, Brand, A, B, C, F, G>
BiFoldRightDispatch<
'a,
FnBrand,
Brand,
A,
B,
C,
&'b Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
Ref,
> for (F, G)
where
Brand: RefBifoldable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
C: 'a,
F: Fn(&A, C) -> C + 'a,
G: Fn(&B, C) -> C + 'a,
{
#[document_signature]
#[document_parameters(
"The initial accumulator value.",
"A reference to the structure to fold."
)]
#[document_returns("The final accumulator value.")]
#[document_examples]
fn dispatch(
self,
z: C,
fa: &'b Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
) -> C {
Brand::ref_bi_fold_right::<FnBrand, A, B, C>(self.0, self.1, z, fa)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use.",
"The brand of the bifoldable structure.",
"The type of the first-position elements.",
"The type of the second-position elements.",
"The monoid type.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters("The closure tuple implementing this dispatch.")]
pub trait BiFoldMapDispatch<
'a,
FnBrand,
Brand: Kind_266801a817966495,
A: 'a,
B: 'a,
M,
FA,
Marker,
> {
#[document_signature]
#[document_parameters("The structure to fold.")]
#[document_returns("The combined monoid value.")]
#[document_examples]
fn dispatch(
self,
fa: FA,
) -> M;
}
#[document_type_parameters(
"The lifetime.",
"The cloneable function brand.",
"The bifoldable brand.",
"The first element type.",
"The second element type.",
"The monoid type.",
"The first closure type.",
"The second closure type."
)]
#[document_parameters("The closure tuple.")]
impl<'a, FnBrand, Brand, A, B, M, F, G>
BiFoldMapDispatch<
'a,
FnBrand,
Brand,
A,
B,
M,
Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
Val,
> for (F, G)
where
Brand: Bifoldable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
M: Monoid + 'a,
F: Fn(A) -> M + 'a,
G: Fn(B) -> M + 'a,
{
#[document_signature]
#[document_parameters("The structure to fold.")]
#[document_returns("The combined monoid value.")]
#[document_examples]
fn dispatch(
self,
fa: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
) -> M {
Brand::bi_fold_map::<FnBrand, A, B, M>(self.0, self.1, fa)
}
}
#[document_type_parameters(
"The lifetime.",
"The borrow lifetime.",
"The cloneable function brand.",
"The bifoldable brand.",
"The first element type.",
"The second element type.",
"The monoid type.",
"The first closure type.",
"The second closure type."
)]
#[document_parameters("The closure tuple.")]
impl<'a, 'b, FnBrand, Brand, A, B, M, F, G>
BiFoldMapDispatch<
'a,
FnBrand,
Brand,
A,
B,
M,
&'b Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
Ref,
> for (F, G)
where
Brand: RefBifoldable,
FnBrand: LiftFn + 'a,
A: Clone + 'a,
B: Clone + 'a,
M: Monoid + 'a,
F: Fn(&A) -> M + 'a,
G: Fn(&B) -> M + 'a,
{
#[document_signature]
#[document_parameters("A reference to the structure to fold.")]
#[document_returns("The combined monoid value.")]
#[document_examples]
fn dispatch(
self,
fa: &'b Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
) -> M {
Brand::ref_bi_fold_map::<FnBrand, A, B, M>(self.0, self.1, fa)
}
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The cloneable function brand.",
"The container type (owned or borrowed). Brand is inferred from this.",
"The type of the first element.",
"The type of the second element.",
"The accumulator type.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"A tuple of (first fold function, second fold function).",
"The initial accumulator value.",
"The bifoldable value (owned for Val, borrowed for Ref)."
)]
#[document_returns("The final accumulator value.")]
#[document_examples]
pub fn bi_fold_left<'a, FnBrand, FA, A: 'a, B: 'a, C: 'a, Marker>(
fg: impl BiFoldLeftDispatch<
'a,
FnBrand,
<FA as InferableBrand_266801a817966495>::Brand,
A,
B,
C,
FA,
Marker,
>,
z: C,
fa: FA,
) -> C
where
FA: InferableBrand_266801a817966495, {
fg.dispatch(z, fa)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The cloneable function brand.",
"The container type (owned or borrowed). Brand is inferred from this.",
"The type of the first element.",
"The type of the second element.",
"The accumulator type.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"A tuple of (first fold function, second fold function).",
"The initial accumulator value.",
"The bifoldable value (owned for Val, borrowed for Ref)."
)]
#[document_returns("The final accumulator value.")]
#[document_examples]
pub fn bi_fold_right<'a, FnBrand, FA, A: 'a, B: 'a, C: 'a, Marker>(
fg: impl BiFoldRightDispatch<
'a,
FnBrand,
<FA as InferableBrand_266801a817966495>::Brand,
A,
B,
C,
FA,
Marker,
>,
z: C,
fa: FA,
) -> C
where
FA: InferableBrand_266801a817966495, {
fg.dispatch(z, fa)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The cloneable function brand.",
"The container type (owned or borrowed). Brand is inferred from this.",
"The type of the first element.",
"The type of the second element.",
"The monoid type to fold into.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"A tuple of (first mapping function, second mapping function).",
"The bifoldable value (owned for Val, borrowed for Ref)."
)]
#[document_returns("The monoidal result of folding.")]
#[document_examples]
pub fn bi_fold_map<'a, FnBrand, FA, A: 'a, B: 'a, M: Monoid + 'a, Marker>(
fg: impl BiFoldMapDispatch<
'a,
FnBrand,
<FA as InferableBrand_266801a817966495>::Brand,
A,
B,
M,
FA,
Marker,
>,
fa: FA,
) -> M
where
FA: InferableBrand_266801a817966495, {
fg.dispatch(fa)
}
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 bifoldable structure.",
"The type of the first-position elements.",
"The type of the second-position elements.",
"The type of the accumulator.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"A tuple of (first step function, second step function).",
"The initial accumulator value.",
"The structure to fold (owned for Val, borrowed for Ref)."
)]
#[document_returns("The final accumulator value.")]
#[document_examples]
pub fn bi_fold_left<
'a,
FnBrand,
Brand: Kind_266801a817966495,
A: 'a,
B: 'a,
C: 'a,
FA,
Marker,
>(
fg: impl BiFoldLeftDispatch<'a, FnBrand, Brand, A, B, C, FA, Marker>,
z: C,
fa: FA,
) -> C {
fg.dispatch(z, fa)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use.",
"The brand of the bifoldable structure.",
"The type of the first-position elements.",
"The type of the second-position elements.",
"The type of the accumulator.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"A tuple of (first step function, second step function).",
"The initial accumulator value.",
"The structure to fold (owned for Val, borrowed for Ref)."
)]
#[document_returns("The final accumulator value.")]
#[document_examples]
pub fn bi_fold_right<
'a,
FnBrand,
Brand: Kind_266801a817966495,
A: 'a,
B: 'a,
C: 'a,
FA,
Marker,
>(
fg: impl BiFoldRightDispatch<'a, FnBrand, Brand, A, B, C, FA, Marker>,
z: C,
fa: FA,
) -> C {
fg.dispatch(z, fa)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the cloneable function to use.",
"The brand of the bifoldable structure.",
"The type of the first-position elements.",
"The type of the second-position elements.",
"The monoid type.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"A tuple of (first mapping function, second mapping function).",
"The structure to fold (owned for Val, borrowed for Ref)."
)]
#[document_returns("The combined monoid value.")]
#[document_examples]
pub fn bi_fold_map<
'a,
FnBrand,
Brand: Kind_266801a817966495,
A: 'a,
B: 'a,
M: Monoid + 'a,
FA,
Marker,
>(
fg: impl BiFoldMapDispatch<'a, FnBrand, Brand, A, B, M, FA, Marker>,
fa: FA,
) -> M {
fg.dispatch(fa)
}
}
}
pub use inner::*;