1pub mod fold;
4pub mod indexed_traversal;
5pub mod traversal;
6
7pub use {
8 fold::*,
9 indexed_traversal::*,
10 traversal::*,
11};
12
13#[fp_macros::document_module]
14mod inner {
15 use {
16 crate::{
17 brands::{
18 optics::*,
19 *,
20 },
21 classes::{
22 profunctor::*,
23 *,
24 },
25 kinds::*,
26 },
27 fp_macros::*,
28 };
29
30 #[document_type_parameters(
35 "The lifetime of the values.",
36 "The profunctor type.",
37 "The source type of the structure.",
38 "The target type of the structure after an update.",
39 "The source type of the focus.",
40 "The target type of the focus after an update."
41 )]
42 #[document_parameters("The optic instance.")]
43 pub trait Optic<'a, P: Profunctor, S: 'a, T: 'a, A: 'a, B: 'a> {
44 #[document_signature]
48 #[document_parameters("The profunctor value to transform.")]
50 #[document_returns("The transformed profunctor value.")]
52 #[document_examples]
53 fn evaluate(
74 &self,
75 pab: Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
76 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
77 }
78
79 #[document_type_parameters(
81 "The lifetime of the values.",
82 "The source type of the structure.",
83 "The target type of the structure after an update.",
84 "The source type of the focus.",
85 "The target type of the focus after an update."
86 )]
87 #[document_parameters("The optic instance.")]
88 pub trait IsoOptic<'a, S: 'a, T: 'a, A: 'a, B: 'a> {
89 #[document_signature]
91 #[document_type_parameters("The profunctor type.")]
93 #[document_parameters("The profunctor value to transform.")]
95 #[document_returns("The transformed profunctor value.")]
97 #[document_examples]
98 fn evaluate<P: Profunctor + 'static>(
118 &self,
119 pab: Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
120 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
121 }
122
123 #[document_type_parameters(
125 "The lifetime of the values.",
126 "The source type of the structure.",
127 "The target type of the structure after an update.",
128 "The source type of the focus.",
129 "The target type of the focus after an update."
130 )]
131 #[document_parameters("The optic instance.")]
132 pub trait LensOptic<'a, S: 'a, T: 'a, A: 'a, B: 'a> {
133 #[document_signature]
135 #[document_type_parameters("The profunctor type.")]
137 #[document_parameters("The profunctor value to transform.")]
139 #[document_returns("The transformed profunctor value.")]
141 #[document_examples]
142 fn evaluate<P: Strong>(
166 &self,
167 pab: Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
168 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
169 }
170
171 #[document_type_parameters(
173 "The lifetime of the values.",
174 "The source type of the structure.",
175 "The target type of the structure after an update.",
176 "The source type of the focus.",
177 "The target type of the focus after an update."
178 )]
179 #[document_parameters("The optic instance.")]
180 pub trait PrismOptic<'a, S: 'a, T: 'a, A: 'a, B: 'a> {
181 #[document_signature]
183 #[document_type_parameters("The profunctor type.")]
185 #[document_parameters("The profunctor value to transform.")]
187 #[document_returns("The transformed profunctor value.")]
189 #[document_examples]
190 fn evaluate<P: Choice>(
213 &self,
214 pab: Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
215 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
216 }
217
218 #[document_type_parameters(
220 "The lifetime of the values.",
221 "The source type of the structure.",
222 "The target type of the structure after an update.",
223 "The source type of the focus.",
224 "The target type of the focus after an update."
225 )]
226 #[document_parameters("The optic instance.")]
227 pub trait AffineTraversalOptic<'a, S: 'a, T: 'a, A: 'a, B: 'a> {
228 #[document_signature]
230 #[document_type_parameters("The profunctor type.")]
232 #[document_parameters("The profunctor value to transform.")]
234 #[document_returns("The transformed profunctor value.")]
236 #[document_examples]
237 fn evaluate<P: Strong + Choice>(
261 &self,
262 pab: Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
263 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
264 }
265
266 #[document_type_parameters(
268 "The lifetime of the values.",
269 "The source type of the structure.",
270 "The target type of the structure after an update.",
271 "The source type of the focus.",
272 "The target type of the focus after an update."
273 )]
274 #[document_parameters("The optic instance.")]
275 pub trait TraversalOptic<'a, S: 'a, T: 'a, A: 'a, B: 'a> {
276 #[document_signature]
278 #[document_type_parameters("The profunctor type.")]
280 #[document_parameters("The profunctor value to transform.")]
282 #[document_returns("The transformed profunctor value.")]
284 #[document_examples]
285 fn evaluate<P: Wander>(
304 &self,
305 pab: Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
306 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
307 }
308
309 #[document_type_parameters(
311 "The lifetime of the values.",
312 "The source type of the structure.",
313 "The focus type."
314 )]
315 #[document_parameters("The optic instance.")]
316 pub trait GetterOptic<'a, S: 'a, A: 'a> {
317 #[document_signature]
319 #[document_type_parameters(
321 "The return type of the forget profunctor.",
322 "The reference-counted pointer type."
323 )]
324 #[document_parameters("The profunctor value to transform.")]
326 #[document_returns("The transformed forget profunctor value.")]
328 #[document_examples]
329 fn evaluate<R: 'a + 'static, PointerBrand: ToDynCloneFn + 'static>(
351 &self,
352 pab: Apply!(<ForgetBrand<PointerBrand, R> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, A>),
353 ) -> Apply!(<ForgetBrand<PointerBrand, R> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, S>);
354 }
355
356 #[document_type_parameters(
358 "The lifetime of the values.",
359 "The source type of the structure.",
360 "The focus type."
361 )]
362 #[document_parameters("The optic instance.")]
363 pub trait FoldOptic<'a, S: 'a, A: 'a> {
364 #[document_signature]
366 #[document_type_parameters("The monoid type.", "The reference-counted pointer type.")]
368 #[document_parameters("The profunctor value to transform.")]
370 #[document_returns("The transformed forget profunctor value.")]
372 #[document_examples]
382 fn evaluate<R: 'a + Monoid + Clone + 'static, PointerBrand: ToDynCloneFn + 'static>(
406 &self,
407 pab: Apply!(<ForgetBrand<PointerBrand, R> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, A>),
408 ) -> Apply!(<ForgetBrand<PointerBrand, R> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, S>);
409 }
410
411 #[document_type_parameters(
413 "The lifetime of the values.",
414 "The reference-counted pointer type.",
415 "The source type of the structure.",
416 "The target type of the structure after an update.",
417 "The source type of the focus.",
418 "The target type of the focus after an update."
419 )]
420 #[document_parameters("The optic instance.")]
421 pub trait SetterOptic<'a, PointerBrand: ToDynCloneFn, S: 'a, T: 'a, A: 'a, B: 'a> {
422 #[document_signature]
424 #[document_parameters("The profunctor value to transform.")]
426 #[document_returns("The transformed function profunctor value.")]
428 #[document_examples]
429 fn evaluate(
454 &self,
455 pab: Apply!(<FnBrand<PointerBrand> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
456 ) -> Apply!(<FnBrand<PointerBrand> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
457 }
458
459 #[document_type_parameters(
461 "The lifetime of the values.",
462 "The index type.",
463 "The source type of the structure.",
464 "The target type of the structure after an update.",
465 "The source type of the focus.",
466 "The target type of the focus after an update."
467 )]
468 #[document_parameters("The optic instance.")]
469 pub trait IndexedLensOptic<'a, I: 'a, S: 'a, T: 'a, A: 'a, B: 'a> {
470 #[document_signature]
472 #[document_type_parameters("The profunctor type.")]
474 #[document_parameters("The indexed profunctor value to transform.")]
476 #[document_returns("The transformed profunctor value.")]
478 #[document_examples]
479 fn evaluate<P: Strong>(
496 &self,
497 pab: crate::types::optics::Indexed<'a, P, I, A, B>,
498 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
499 }
500
501 #[document_type_parameters(
503 "The lifetime of the values.",
504 "The index type.",
505 "The source type of the structure.",
506 "The target type of the structure after an update.",
507 "The source type of the focus.",
508 "The target type of the focus after an update."
509 )]
510 #[document_parameters("The optic instance.")]
511 pub trait IndexedTraversalOptic<'a, I: 'a, S: 'a, T: 'a, A: 'a, B: 'a> {
512 #[document_signature]
514 #[document_type_parameters("The profunctor type.")]
516 #[document_parameters("The indexed profunctor value to transform.")]
518 #[document_returns("The transformed profunctor value.")]
520 #[document_examples]
521 fn evaluate<P: Wander>(
538 &self,
539 pab: crate::types::optics::Indexed<'a, P, I, A, B>,
540 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
541 }
542
543 #[document_type_parameters(
545 "The lifetime of the values.",
546 "The index type.",
547 "The source type of the structure.",
548 "The focus type."
549 )]
550 #[document_parameters("The optic instance.")]
551 pub trait IndexedGetterOptic<'a, I: 'a, S: 'a, A: 'a> {
552 #[document_signature]
554 #[document_type_parameters(
556 "The return type of the forget profunctor.",
557 "The reference-counted pointer type."
558 )]
559 #[document_parameters("The indexed profunctor value to transform.")]
561 #[document_returns("The transformed forget profunctor value.")]
563 #[document_examples]
564 fn evaluate<R: 'a + 'static, PointerBrand: ToDynCloneFn + 'static>(
586 &self,
587 pab: crate::types::optics::Indexed<'a, ForgetBrand<PointerBrand, R>, I, A, A>,
588 ) -> Apply!(<ForgetBrand<PointerBrand, R> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, S>);
589 }
590
591 #[document_type_parameters(
593 "The lifetime of the values.",
594 "The index type.",
595 "The source type of the structure.",
596 "The focus type."
597 )]
598 #[document_parameters("The optic instance.")]
599 pub trait IndexedFoldOptic<'a, I: 'a, S: 'a, A: 'a> {
600 #[document_signature]
602 #[document_type_parameters("The monoid type.", "The reference-counted pointer type.")]
604 #[document_parameters("The indexed profunctor value to transform.")]
606 #[document_returns("The transformed forget profunctor value.")]
608 #[document_examples]
609 fn evaluate<R: 'a + Monoid + Clone + 'static, PointerBrand: ToDynCloneFn + 'static>(
642 &self,
643 pab: crate::types::optics::Indexed<'a, ForgetBrand<PointerBrand, R>, I, A, A>,
644 ) -> Apply!(<ForgetBrand<PointerBrand, R> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, S>);
645 }
646
647 #[document_type_parameters(
649 "The lifetime of the values.",
650 "The reference-counted pointer type.",
651 "The index type.",
652 "The source type of the structure.",
653 "The target type of the structure after an update.",
654 "The source type of the focus.",
655 "The target type of the focus after an update."
656 )]
657 #[document_parameters("The optic instance.")]
658 pub trait IndexedSetterOptic<'a, PointerBrand: ToDynCloneFn, I: 'a, S: 'a, T: 'a, A: 'a, B: 'a>
659 {
660 #[document_signature]
662 #[document_parameters("The indexed profunctor value to transform.")]
664 #[document_returns("The transformed function profunctor value.")]
666 #[document_examples]
667 fn evaluate(
692 &self,
693 pab: crate::types::optics::Indexed<'a, FnBrand<PointerBrand>, I, A, B>,
694 ) -> Apply!(<FnBrand<PointerBrand> as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
695 }
696
697 #[document_type_parameters(
699 "The lifetime of the values.",
700 "The cloneable function brand used by the profunctor's `Closed` instance.",
701 "The source type of the structure.",
702 "The target type of the structure after an update.",
703 "The source type of the focus.",
704 "The target type of the focus after an update."
705 )]
706 #[document_parameters("The optic instance.")]
707 pub trait GrateOptic<'a, FunctionBrand: LiftFn, S: 'a, T: 'a, A: 'a, B: 'a> {
708 #[document_signature]
710 #[document_type_parameters("The profunctor type.")]
712 #[document_parameters("The profunctor value to transform.")]
714 #[document_returns("The transformed profunctor value.")]
716 #[document_examples]
717 fn evaluate<P: Closed<FunctionBrand>>(
736 &self,
737 pab: Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
738 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
739 }
740
741 #[document_type_parameters(
743 "The lifetime of the values.",
744 "The source type of the structure.",
745 "The target type of the structure after an update.",
746 "The source type of the focus.",
747 "The target type of the focus after an update."
748 )]
749 #[document_parameters("The optic instance.")]
750 pub trait ReviewOptic<'a, S: 'a, T: 'a, A: 'a, B: 'a> {
751 #[document_signature]
753 #[document_parameters("The profunctor value to transform.")]
755 #[document_returns("The transformed tagged profunctor value.")]
757 #[document_examples]
758 fn evaluate(
781 &self,
782 pab: Apply!(<TaggedBrand as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, A, B>),
783 ) -> Apply!(<TaggedBrand as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
784 }
785
786 #[document_type_parameters(
788 "The lifetime of the values.",
789 "The profunctor type.",
790 "The index type.",
791 "The source type of the structure.",
792 "The target type of the structure.",
793 "The source type of the focus.",
794 "The target type of the focus."
795 )]
796 #[document_parameters("The adapter instance.")]
797 pub trait IndexedOpticAdapter<'a, P: Profunctor, I, S, T, A, B> {
798 #[document_signature]
800 #[document_parameters("The indexed profunctor value.")]
802 #[document_returns("The transformed profunctor value.")]
804 #[document_examples]
805 fn evaluate_indexed(
822 &self,
823 pab: crate::types::optics::Indexed<'a, P, I, A, B>,
824 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
825 }
826
827 #[document_type_parameters(
829 "The lifetime of the values.",
830 "The profunctor type.",
831 "The index type.",
832 "The source type of the structure.",
833 "The target type of the structure.",
834 "The source type of the focus.",
835 "The target type of the focus."
836 )]
837 #[document_parameters("The adapter instance.")]
838 pub trait IndexedOpticAdapterDiscardsFocus<'a, P: Profunctor, I, S, T, A, B> {
839 #[document_signature]
841 #[document_parameters("The indexed profunctor value.")]
843 #[document_returns("The transformed profunctor value.")]
845 #[document_examples]
846 fn evaluate_indexed_discards_focus(
863 &self,
864 pab: crate::types::optics::Indexed<'a, P, I, A, B>,
865 ) -> Apply!(<P as Kind!( type Of<'b, T: 'b, U: 'b>: 'b; )>::Of<'a, S, T>);
866 }
867}
868
869pub use inner::*;