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