#[fp_macros::document_module]
mod inner {
use {
crate::{
classes::*,
kinds::*,
},
fp_macros::*,
};
#[document_examples]
pub trait Strong: Profunctor {
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The input type of the profunctor.",
"The output type of the profunctor.",
"The type of the second component (threaded through unchanged)."
)]
#[document_parameters("The profunctor instance to lift.")]
#[document_returns("A new profunctor that operates on pairs.")]
#[document_examples]
fn first<'a, A: 'a, B: 'a, C: 'a>(
pab: Apply!(<Self as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, A, B>)
) -> Apply!(<Self as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, (A, C), (B, C)>);
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The input type of the profunctor.",
"The output type of the profunctor.",
"The type of the first component (threaded through unchanged)."
)]
#[document_parameters("The profunctor instance to lift.")]
#[document_returns("A new profunctor that operates on pairs.")]
#[document_examples]
fn second<'a, A: 'a, B: 'a, C: 'a>(
pab: Apply!(<Self as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, A, B>)
) -> Apply!(<Self as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, (C, A), (C, B)>) {
Self::dimap(|(c, a)| (a, c), |(b, c)| (c, b), Self::first(pab))
}
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the strong profunctor.",
"The input type of the profunctor.",
"The output type of the profunctor.",
"The type of the second component (threaded through unchanged)."
)]
#[document_parameters("The profunctor instance to lift.")]
#[document_returns("A new profunctor that operates on pairs.")]
#[document_examples]
pub fn first<'a, Brand: Strong, A: 'a, B: 'a, C: 'a>(
pab: Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, A, B>)
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, (A, C), (B, C)>) {
Brand::first(pab)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the strong profunctor.",
"The input type of the profunctor.",
"The output type of the profunctor.",
"The type of the first component (threaded through unchanged)."
)]
#[document_parameters("The profunctor instance to lift.")]
#[document_returns("A new profunctor that operates on pairs.")]
#[document_examples]
pub fn second<'a, Brand: Strong, A: 'a, B: 'a, C: 'a>(
pab: Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, A, B>)
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, (C, A), (C, B)>) {
Brand::second(pab)
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the strong profunctor.",
"The input type of the first profunctor.",
"The output type of the first profunctor.",
"The input type of the second profunctor.",
"The output type of the second profunctor."
)]
#[document_parameters(
"The profunctor acting on the first component.",
"The profunctor acting on the second component."
)]
#[document_returns(
"A new profunctor that maps the first component via `l` and the second via `r`."
)]
#[document_examples]
pub fn split_strong<'a, Brand: Semigroupoid + Strong, A: 'a, B: 'a, C: 'a, D: 'a>(
l: Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, A, B>),
r: Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, C, D>),
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, (A, C), (B, D)>) {
Brand::compose(Brand::second(r), Brand::first(l))
}
#[document_signature]
#[document_type_parameters(
"The lifetime of the values.",
"The brand of the strong profunctor.",
"The shared input type (must be Clone).",
"The output type of the first profunctor.",
"The output type of the second profunctor."
)]
#[document_parameters(
"The profunctor producing the first component.",
"The profunctor producing the second component."
)]
#[document_returns(
"A new profunctor that feeds the input to both `l` and `r`, collecting results in a pair."
)]
#[document_examples]
pub fn fan_out<'a, Brand: Semigroupoid + Strong, A: 'a + Clone, B: 'a, C: 'a>(
l: Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, A, B>),
r: Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, A, C>),
) -> Apply!(<Brand as Kind!( type Of<'a, T: 'a, U: 'a>: 'a; )>::Of<'a, A, (B, C)>) {
Brand::lmap(|a: A| (a.clone(), a), split_strong::<Brand, A, B, A, C>(l, r))
}
}
pub use inner::*;