fp_library/classes/
ref_traversable.rs1#[fp_macros::document_module]
18mod inner {
19 use {
20 crate::{
21 classes::*,
22 kinds::*,
23 },
24 fp_macros::*,
25 };
26
27 #[kind(type Of<'a, A: 'a>: 'a;)]
35 pub trait RefTraversable: RefFunctor + RefFoldable {
36 #[document_signature]
39 #[document_type_parameters(
41 "The lifetime of the elements.",
42 "The brand of the cloneable function wrapper.",
43 "The type of the elements in the input structure.",
44 "The type of the elements in the output structure.",
45 "The applicative functor brand for the computation."
46 )]
47 #[document_parameters(
49 "The function to apply to each element reference.",
50 "The structure to traverse."
51 )]
52 #[document_returns("The combined result in the applicative context.")]
54 #[document_examples]
55 fn ref_traverse<'a, FnBrand, A: 'a + Clone, B: 'a + Clone, F: Applicative>(
68 func: impl Fn(&A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>) + 'a,
69 ta: &Apply!(<Self as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
70 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Self as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>)>)
71 where
72 FnBrand: LiftFn + 'a,
73 Apply!(<Self as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone,
74 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone;
75 }
76
77 #[document_signature]
82 #[document_type_parameters(
84 "The lifetime of the elements.",
85 "The brand of the structure.",
86 "The brand of the cloneable function wrapper.",
87 "The type of the input elements.",
88 "The type of the output elements.",
89 "The applicative functor brand."
90 )]
91 #[document_parameters(
93 "The function to apply to each element reference.",
94 "The structure to traverse."
95 )]
96 #[document_returns("The combined result in the applicative context.")]
98 #[document_examples]
99 pub fn ref_traverse<
112 'a,
113 Brand: RefTraversable,
114 FnBrand,
115 A: 'a + Clone,
116 B: 'a + Clone,
117 F: Applicative,
118 >(
119 func: impl Fn(&A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>) + 'a,
120 ta: &Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
121 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>)>)
122 where
123 FnBrand: LiftFn + 'a,
124 Apply!(<Brand as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone,
125 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone, {
126 Brand::ref_traverse::<FnBrand, A, B, F>(func, ta)
127 }
128}
129
130pub use inner::*;