#[fp_macros::document_module]
pub(crate) mod inner {
use {
crate::{
classes::{
Bifunctor,
RefBifunctor,
},
dispatch::{
Ref,
Val,
},
kinds::*,
},
fp_macros::*,
};
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the bifunctor.",
"The type of the first value.",
"The type of the second value.",
"The type of the second result.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters("The closure implementing this dispatch.")]
pub trait MapSecondDispatch<'a, Brand: Kind_266801a817966495, A: 'a, B: 'a, C: 'a, FA, Marker> {
#[document_signature]
#[document_parameters("The bifunctor value.")]
#[document_returns("A new bifunctor with the second value transformed.")]
#[document_examples]
fn dispatch(
self,
fa: FA,
) -> Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, C>);
}
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the bifunctor.",
"The type of the first value.",
"The type of the second value.",
"The type of the second result.",
"The closure type."
)]
#[document_parameters("The closure that takes owned values.")]
impl<'a, Brand, A, B, C, F>
MapSecondDispatch<
'a,
Brand,
A,
B,
C,
Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
Val,
> for F
where
Brand: Bifunctor,
A: 'a,
B: 'a,
C: 'a,
F: Fn(B) -> C + 'a,
{
#[document_signature]
#[document_parameters("The bifunctor value.")]
#[document_returns("A new bifunctor with the second value transformed.")]
#[document_examples]
fn dispatch(
self,
fa: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
) -> Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, C>) {
Brand::map_second(self, fa)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The borrow lifetime.",
"The brand of the bifunctor.",
"The type of the first value (must be Clone).",
"The type of the second value.",
"The type of the second result.",
"The closure type."
)]
#[document_parameters("The closure that takes references.")]
impl<'a, 'b, Brand, A, B, C, F>
MapSecondDispatch<
'a,
Brand,
A,
B,
C,
&'b Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
Ref,
> for F
where
Brand: RefBifunctor,
A: Clone + 'a,
B: 'a,
C: 'a,
F: Fn(&B) -> C + 'a,
{
#[document_signature]
#[document_parameters("A reference to the bifunctor value.")]
#[document_returns("A new bifunctor with the second value transformed.")]
#[document_examples]
fn dispatch(
self,
fa: &'b Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
) -> Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, C>) {
Brand::ref_map_second(self, fa)
}
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The container type (owned or borrowed). Brand is inferred from this.",
"The type of the first value.",
"The type of the second value.",
"The type of the second result.",
"The brand, inferred via InferableBrand from FA and the element types."
)]
#[document_parameters(
"The function to apply to the second value.",
"The bifunctor value (owned or borrowed)."
)]
#[document_returns("A new bifunctor with the second value transformed.")]
#[document_examples]
pub fn map_second<'a, FA, A: 'a, B: 'a, C: 'a, Brand>(
g: impl MapSecondDispatch<
'a,
Brand,
A,
B,
C,
FA,
<FA as InferableBrand_266801a817966495<'a, Brand, A, B>>::Marker,
>,
p: FA,
) -> Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, C>)
where
Brand: Kind_266801a817966495,
FA: InferableBrand_266801a817966495<'a, Brand, A, B>, {
g.dispatch(p)
}
pub mod explicit {
use super::*;
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the bifunctor.",
"The type of the first value.",
"The type of the second value.",
"The type of the second result.",
"The container type (owned or borrowed), inferred from the argument.",
"Dispatch marker type, inferred automatically."
)]
#[document_parameters(
"The function to apply to the second value.",
"The bifunctor value (owned for Val, borrowed for Ref)."
)]
#[document_returns("A new bifunctor with the second value transformed.")]
#[document_examples]
pub fn map_second<'a, Brand: Kind_266801a817966495, A: 'a, B: 'a, C: 'a, FA, Marker>(
g: impl MapSecondDispatch<'a, Brand, A, B, C, FA, Marker>,
p: FA,
) -> Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, C>) {
g.dispatch(p)
}
}
}
pub use inner::*;