1#[fp_macros::document_module]
21mod inner {
22 use {
23 crate::{
24 classes::*,
25 functions::*,
26 kinds::*,
27 },
28 fp_macros::*,
29 };
30
31 pub trait Bitraversable: Bifunctor + Bifoldable {
50 #[document_signature]
55 #[document_type_parameters(
57 "The lifetime of the values.",
58 "The type of the first-position elements.",
59 "The type of the second-position elements.",
60 "The output type for first-position elements.",
61 "The output type for second-position elements.",
62 "The applicative context."
63 )]
64 #[document_parameters(
66 "The function for first-position elements.",
67 "The function for second-position elements.",
68 "The bitraversable structure to traverse."
69 )]
70 #[document_returns("The transformed structure wrapped in the applicative context.")]
72 #[document_examples]
73 fn bi_traverse<
89 'a,
90 A: 'a + Clone,
91 B: 'a + Clone,
92 C: 'a + Clone,
93 D: 'a + Clone,
94 F: Applicative,
95 >(
96 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
97 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
98 p: Apply!(<Self as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
99 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Self as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, C, D>)>);
100
101 #[document_signature]
106 #[document_type_parameters(
108 "The lifetime of the values.",
109 "The type of the first-position elements.",
110 "The type of the second-position elements.",
111 "The applicative context."
112 )]
113 #[document_parameters("The bitraversable structure containing applicative values.")]
115 #[document_returns("The applicative context wrapping the bitraversable structure.")]
117 #[document_examples]
118 fn bi_sequence<'a, A: 'a + Clone, B: 'a + Clone, F: Applicative>(
130 ta: Apply!(<Self as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>), Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>)>)
131 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Self as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>)>)
132 where
133 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>): Clone,
134 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone, {
135 Self::bi_traverse::<
136 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
137 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
138 A,
139 B,
140 F,
141 >(identity, identity, ta)
142 }
143 }
144
145 #[document_signature]
149 #[document_type_parameters(
151 "The lifetime of the values.",
152 "The brand of the bitraversable structure.",
153 "The type of the first-position elements.",
154 "The type of the second-position elements.",
155 "The output type for first-position elements.",
156 "The output type for second-position elements.",
157 "The applicative context."
158 )]
159 #[document_parameters(
161 "The function for first-position elements.",
162 "The function for second-position elements.",
163 "The bitraversable structure to traverse."
164 )]
165 #[document_returns("The transformed structure wrapped in the applicative context.")]
167 #[document_examples]
168 pub fn bi_traverse<
184 'a,
185 Brand: Bitraversable,
186 A: 'a + Clone,
187 B: 'a + Clone,
188 C: 'a + Clone,
189 D: 'a + Clone,
190 F: Applicative,
191 >(
192 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
193 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
194 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
195 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, C, D>)>)
196 {
197 Brand::bi_traverse::<A, B, C, D, F>(f, g, p)
198 }
199
200 #[document_signature]
204 #[document_type_parameters(
206 "The lifetime of the values.",
207 "The brand of the bitraversable structure.",
208 "The type of the first-position elements.",
209 "The type of the second-position elements.",
210 "The applicative context."
211 )]
212 #[document_parameters("The bitraversable structure containing applicative values.")]
214 #[document_returns("The applicative context wrapping the bitraversable structure.")]
216 #[document_examples]
217 pub fn bi_sequence<'a, Brand: Bitraversable, A: 'a + Clone, B: 'a + Clone, F: Applicative>(
229 ta: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>), Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>)>)
230 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>)>)
231 where
232 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>): Clone,
233 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone, {
234 Brand::bi_sequence::<A, B, F>(ta)
235 }
236
237 #[document_signature]
241 #[document_type_parameters(
243 "The lifetime of the values.",
244 "The brand of the bitraversable structure.",
245 "The type of the first-position elements.",
246 "The type of the second-position elements (unchanged).",
247 "The output type for first-position elements.",
248 "The applicative context."
249 )]
250 #[document_parameters(
252 "The function for first-position elements.",
253 "The bitraversable structure to traverse."
254 )]
255 #[document_returns("The transformed structure wrapped in the applicative context.")]
257 #[document_examples]
258 pub fn traverse_left<
270 'a,
271 Brand: Bitraversable,
272 A: 'a + Clone,
273 B: 'a + Clone,
274 C: 'a + Clone,
275 F: Applicative,
276 >(
277 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
278 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
279 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, C, B>)>)
280 {
281 Brand::bi_traverse::<A, B, C, B, F>(f, |b| F::pure(b), p)
282 }
283
284 #[document_signature]
288 #[document_type_parameters(
290 "The lifetime of the values.",
291 "The brand of the bitraversable structure.",
292 "The type of the first-position elements (unchanged).",
293 "The type of the second-position elements.",
294 "The output type for second-position elements.",
295 "The applicative context."
296 )]
297 #[document_parameters(
299 "The function for second-position elements.",
300 "The bitraversable structure to traverse."
301 )]
302 #[document_returns("The transformed structure wrapped in the applicative context.")]
304 #[document_examples]
305 pub fn traverse_right<
317 'a,
318 Brand: Bitraversable,
319 A: 'a + Clone,
320 B: 'a + Clone,
321 D: 'a + Clone,
322 F: Applicative,
323 >(
324 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
325 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
326 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, D>)>)
327 {
328 Brand::bi_traverse::<A, B, A, D, F>(|a| F::pure(a), g, p)
329 }
330
331 #[document_signature]
335 #[document_type_parameters(
337 "The lifetime of the values.",
338 "The brand of the bitraversable structure.",
339 "The type of the first-position elements.",
340 "The type of the second-position elements.",
341 "The output type for first-position elements.",
342 "The output type for second-position elements.",
343 "The applicative context."
344 )]
345 #[document_parameters(
347 "The bitraversable structure to traverse.",
348 "The function for first-position elements.",
349 "The function for second-position elements."
350 )]
351 #[document_returns("The transformed structure wrapped in the applicative context.")]
353 #[document_examples]
354 pub fn bi_for<
370 'a,
371 Brand: Bitraversable,
372 A: 'a + Clone,
373 B: 'a + Clone,
374 C: 'a + Clone,
375 D: 'a + Clone,
376 F: Applicative,
377 >(
378 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
379 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
380 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
381 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, C, D>)>)
382 {
383 Brand::bi_traverse::<A, B, C, D, F>(f, g, p)
384 }
385
386 #[document_signature]
390 #[document_type_parameters(
392 "The lifetime of the values.",
393 "The brand of the bitraversable structure.",
394 "The type of the first-position elements.",
395 "The type of the second-position elements (unchanged).",
396 "The output type for first-position elements.",
397 "The applicative context."
398 )]
399 #[document_parameters(
401 "The bitraversable structure to traverse.",
402 "The function for first-position elements."
403 )]
404 #[document_returns("The transformed structure wrapped in the applicative context.")]
406 #[document_examples]
407 pub fn for_left<
419 'a,
420 Brand: Bitraversable,
421 A: 'a + Clone,
422 B: 'a + Clone,
423 C: 'a + Clone,
424 F: Applicative,
425 >(
426 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
427 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
428 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, C, B>)>)
429 {
430 Brand::bi_traverse::<A, B, C, B, F>(f, |b| F::pure(b), p)
431 }
432
433 #[document_signature]
437 #[document_type_parameters(
439 "The lifetime of the values.",
440 "The brand of the bitraversable structure.",
441 "The type of the first-position elements (unchanged).",
442 "The type of the second-position elements.",
443 "The output type for second-position elements.",
444 "The applicative context."
445 )]
446 #[document_parameters(
448 "The bitraversable structure to traverse.",
449 "The function for second-position elements."
450 )]
451 #[document_returns("The transformed structure wrapped in the applicative context.")]
453 #[document_examples]
454 pub fn for_right<
466 'a,
467 Brand: Bitraversable,
468 A: 'a + Clone,
469 B: 'a + Clone,
470 D: 'a + Clone,
471 F: Applicative,
472 >(
473 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
474 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
475 ) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, D>)>)
476 {
477 Brand::bi_traverse::<A, B, A, D, F>(|a| F::pure(a), g, p)
478 }
479}
480
481pub use inner::*;