#[fp_macros::document_module]
mod inner {
use {
crate::{
Apply,
brands::{
FnBrand,
optics::*,
},
classes::{
optics::*,
*,
},
kinds::*,
types::optics::Tagged,
},
fp_macros::*,
std::marker::PhantomData,
};
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The source type of the structure.",
"The target type of the structure.",
"The source type of the focus.",
"The target type of the focus."
)]
pub struct Review<'a, PointerBrand, S, T, A, B>
where
PointerBrand: ToDynCloneFn,
S: 'a,
T: 'a,
A: 'a,
B: 'a, {
pub review_fn: Apply!(<FnBrand<PointerBrand> as Kind!( type Of<'b, U: 'b, V: 'b>: 'b; )>::Of<'a, B, T>),
pub(crate) _phantom: PhantomData<&'a (S, A)>,
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The source type of the structure.",
"The target type of the structure.",
"The source type of the focus.",
"The target type of the focus."
)]
#[document_parameters("The review instance.")]
impl<'a, PointerBrand, S, T, A, B> Clone for Review<'a, PointerBrand, S, T, A, B>
where
PointerBrand: ToDynCloneFn,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
{
#[document_signature]
#[document_returns("A new `Review` instance that is a copy of the original.")]
#[document_examples]
fn clone(&self) -> Self {
Review {
review_fn: self.review_fn.clone(),
_phantom: PhantomData,
}
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The source type of the structure.",
"The target type of the structure.",
"The source type of the focus.",
"The target type of the focus."
)]
#[document_parameters("The review instance.")]
impl<'a, PointerBrand, S, T, A, B> Review<'a, PointerBrand, S, T, A, B>
where
PointerBrand: ToDynCloneFn,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
{
#[document_signature]
#[document_parameters("The review function.")]
#[document_returns("A new instance of the type.")]
#[document_examples]
pub fn new(review: impl 'a + Fn(B) -> T) -> Self {
Review {
review_fn: <FnBrand<PointerBrand> as LiftFn>::new(review),
_phantom: PhantomData,
}
}
#[document_signature]
#[document_parameters("The focus value to review.")]
#[document_returns("The structure containing the focus value.")]
#[document_examples]
pub fn review(
&self,
b: B,
) -> T {
(self.review_fn)(b)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The source type of the structure.",
"The target type of the structure.",
"The source type of the focus.",
"The target type of the focus."
)]
#[document_parameters("The review instance.")]
impl<'a, PointerBrand, S, T, A, B> Optic<'a, TaggedBrand, S, T, A, B>
for Review<'a, PointerBrand, S, T, A, B>
where
PointerBrand: ToDynCloneFn,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
{
#[document_signature]
#[document_parameters("The profunctor value to transform.")]
#[document_returns("The transformed profunctor value.")]
#[document_examples]
fn evaluate(
&self,
pab: Apply!(<TaggedBrand as Kind!( type Of<'b, X: 'b, Y: 'b>: 'b; )>::Of<'a, A, B>),
) -> Apply!(<TaggedBrand as Kind!( type Of<'b, X: 'b, Y: 'b>: 'b; )>::Of<'a, S, T>) {
let review = self.review_fn.clone();
Tagged::new(review(pab.0))
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The source type of the structure.",
"The target type of the structure.",
"The source type of the focus.",
"The target type of the focus."
)]
#[document_parameters("The review instance.")]
impl<'a, PointerBrand, S, T, A, B> ReviewOptic<'a, S, T, A, B>
for Review<'a, PointerBrand, S, T, A, B>
where
PointerBrand: ToDynCloneFn,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
{
#[document_signature]
#[document_parameters("The profunctor value to transform.")]
#[document_returns("The transformed profunctor value.")]
#[document_examples]
fn evaluate(
&self,
pab: Apply!(<TaggedBrand as Kind!( type Of<'b, X: 'b, Y: 'b>: 'b; )>::Of<'a, A, B>),
) -> Apply!(<TaggedBrand as Kind!( type Of<'b, X: 'b, Y: 'b>: 'b; )>::Of<'a, S, T>) {
Optic::<TaggedBrand, S, T, A, B>::evaluate(self, pab)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The type of the structure.",
"The type of the focus."
)]
pub struct ReviewPrime<'a, PointerBrand, S, A>
where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a, {
pub review_fn: Apply!(<FnBrand<PointerBrand> as Kind!( type Of<'b, U: 'b, V: 'b>: 'b; )>::Of<'a, A, S>),
pub(crate) _phantom: PhantomData<PointerBrand>,
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The type of the structure.",
"The type of the focus."
)]
#[document_parameters("The review instance.")]
impl<'a, PointerBrand, S, A> Clone for ReviewPrime<'a, PointerBrand, S, A>
where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
{
#[document_signature]
#[document_returns("A new `ReviewPrime` instance that is a copy of the original.")]
#[document_examples]
fn clone(&self) -> Self {
ReviewPrime {
review_fn: self.review_fn.clone(),
_phantom: PhantomData,
}
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The type of the structure.",
"The type of the focus."
)]
#[document_parameters("The review instance.")]
impl<'a, PointerBrand, S, A> ReviewPrime<'a, PointerBrand, S, A>
where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
{
#[document_signature]
#[document_parameters("The review function.")]
#[document_returns("A new instance of the type.")]
#[document_examples]
pub fn new(review: impl 'a + Fn(A) -> S) -> Self {
ReviewPrime {
review_fn: <FnBrand<PointerBrand> as LiftFn>::new(review),
_phantom: PhantomData,
}
}
#[document_signature]
#[document_parameters("The focus value to review.")]
#[document_returns("The structure containing the focus value.")]
#[document_examples]
pub fn review(
&self,
a: A,
) -> S {
(self.review_fn)(a)
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The type of the structure.",
"The type of the focus."
)]
#[document_parameters("The review instance.")]
impl<'a, PointerBrand, S, A> Optic<'a, TaggedBrand, S, S, A, A>
for ReviewPrime<'a, PointerBrand, S, A>
where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
{
#[document_signature]
#[document_parameters("The profunctor value to transform.")]
#[document_returns("The transformed profunctor value.")]
#[document_examples]
fn evaluate(
&self,
pab: Apply!(<TaggedBrand as Kind!( type Of<'b, X: 'b, Y: 'b>: 'b; )>::Of<'a, A, A>),
) -> Apply!(<TaggedBrand as Kind!( type Of<'b, X: 'b, Y: 'b>: 'b; )>::Of<'a, S, S>) {
let review = self.review_fn.clone();
Tagged::new(review(pab.0))
}
}
#[document_type_parameters(
"The lifetime of the values.",
"The reference-counted pointer type.",
"The type of the structure.",
"The type of the focus."
)]
#[document_parameters("The review instance.")]
impl<'a, PointerBrand, S, A> ReviewOptic<'a, S, S, A, A> for ReviewPrime<'a, PointerBrand, S, A>
where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
{
#[document_signature]
#[document_parameters("The profunctor value to transform.")]
#[document_returns("The transformed profunctor value.")]
#[document_examples]
fn evaluate(
&self,
pab: Apply!(<TaggedBrand as Kind!( type Of<'b, X: 'b, Y: 'b>: 'b; )>::Of<'a, A, A>),
) -> Apply!(<TaggedBrand as Kind!( type Of<'b, X: 'b, Y: 'b>: 'b; )>::Of<'a, S, S>) {
Optic::<TaggedBrand, S, S, A, A>::evaluate(self, pab)
}
}
}
pub use inner::*;