1#[fp_macros::document_module]
20mod inner {
21 use {
22 crate::{
23 classes::*,
24 functions::*,
25 kinds::*,
26 },
27 fp_macros::*,
28 };
29
30 #[document_examples]
48 pub trait Bitraversable: Bifunctor + Bifoldable {
90 #[document_signature]
95 #[document_type_parameters(
97 "The lifetime of the values.",
98 "The type of the first-position elements.",
99 "The type of the second-position elements.",
100 "The output type for first-position elements.",
101 "The output type for second-position elements.",
102 "The applicative context."
103 )]
104 #[document_parameters(
106 "The function for first-position elements.",
107 "The function for second-position elements.",
108 "The bitraversable structure to traverse."
109 )]
110 #[document_returns("The transformed structure wrapped in the applicative context.")]
112 #[document_examples]
113 fn bi_traverse<
128 'a,
129 A: 'a + Clone,
130 B: 'a + Clone,
131 C: 'a + Clone,
132 D: 'a + Clone,
133 F: Applicative,
134 >(
135 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
136 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
137 p: Apply!(<Self as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
138 ) -> 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>)>);
139
140 #[document_signature]
145 #[document_type_parameters(
147 "The lifetime of the values.",
148 "The type of the first-position elements.",
149 "The type of the second-position elements.",
150 "The applicative context."
151 )]
152 #[document_parameters("The bitraversable structure containing applicative values.")]
154 #[document_returns("The applicative context wrapping the bitraversable structure.")]
156 #[document_examples]
157 fn bi_sequence<'a, A: 'a + Clone, B: 'a + Clone, F: Applicative>(
169 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>)>)
170 ) -> 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>)>)
171 where
172 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>): Clone,
173 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone, {
174 Self::bi_traverse::<
175 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
176 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
177 A,
178 B,
179 F,
180 >(identity, identity, ta)
181 }
182 }
183
184 #[document_signature]
188 #[document_type_parameters(
190 "The lifetime of the values.",
191 "The brand of the bitraversable structure.",
192 "The type of the first-position elements.",
193 "The type of the second-position elements.",
194 "The output type for first-position elements.",
195 "The output type for second-position elements.",
196 "The applicative context."
197 )]
198 #[document_parameters(
200 "The function for first-position elements.",
201 "The function for second-position elements.",
202 "The bitraversable structure to traverse."
203 )]
204 #[document_returns("The transformed structure wrapped in the applicative context.")]
206 #[document_examples]
207 pub fn bi_traverse<
222 'a,
223 Brand: Bitraversable,
224 A: 'a + Clone,
225 B: 'a + Clone,
226 C: 'a + Clone,
227 D: 'a + Clone,
228 F: Applicative,
229 >(
230 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
231 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
232 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
233 ) -> 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>)>)
234 {
235 Brand::bi_traverse::<A, B, C, D, F>(f, g, p)
236 }
237
238 #[document_signature]
242 #[document_type_parameters(
244 "The lifetime of the values.",
245 "The brand of the bitraversable structure.",
246 "The type of the first-position elements.",
247 "The type of the second-position elements.",
248 "The applicative context."
249 )]
250 #[document_parameters("The bitraversable structure containing applicative values.")]
252 #[document_returns("The applicative context wrapping the bitraversable structure.")]
254 #[document_examples]
255 pub fn bi_sequence<'a, Brand: Bitraversable, A: 'a + Clone, B: 'a + Clone, F: Applicative>(
267 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>)>)
268 ) -> 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>)>)
269 where
270 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>): Clone,
271 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone, {
272 Brand::bi_sequence::<A, B, F>(ta)
273 }
274
275 #[document_signature]
279 #[document_type_parameters(
281 "The lifetime of the values.",
282 "The brand of the bitraversable structure.",
283 "The type of the first-position elements.",
284 "The type of the second-position elements (unchanged).",
285 "The output type for first-position elements.",
286 "The applicative context."
287 )]
288 #[document_parameters(
290 "The function for first-position elements.",
291 "The bitraversable structure to traverse."
292 )]
293 #[document_returns("The transformed structure wrapped in the applicative context.")]
295 #[document_examples]
296 pub fn traverse_left<
308 'a,
309 Brand: Bitraversable,
310 A: 'a + Clone,
311 B: 'a + Clone,
312 C: 'a + Clone,
313 F: Applicative,
314 >(
315 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
316 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
317 ) -> 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>)>)
318 {
319 Brand::bi_traverse::<A, B, C, B, F>(f, |b| F::pure(b), p)
320 }
321
322 #[document_signature]
326 #[document_type_parameters(
328 "The lifetime of the values.",
329 "The brand of the bitraversable structure.",
330 "The type of the first-position elements (unchanged).",
331 "The type of the second-position elements.",
332 "The output type for second-position elements.",
333 "The applicative context."
334 )]
335 #[document_parameters(
337 "The function for second-position elements.",
338 "The bitraversable structure to traverse."
339 )]
340 #[document_returns("The transformed structure wrapped in the applicative context.")]
342 #[document_examples]
343 pub fn traverse_right<
355 'a,
356 Brand: Bitraversable,
357 A: 'a + Clone,
358 B: 'a + Clone,
359 D: 'a + Clone,
360 F: Applicative,
361 >(
362 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
363 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
364 ) -> 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>)>)
365 {
366 Brand::bi_traverse::<A, B, A, D, F>(|a| F::pure(a), g, p)
367 }
368
369 #[document_signature]
373 #[document_type_parameters(
375 "The lifetime of the values.",
376 "The brand of the bitraversable structure.",
377 "The type of the first-position elements.",
378 "The type of the second-position elements.",
379 "The output type for first-position elements.",
380 "The output type for second-position elements.",
381 "The applicative context."
382 )]
383 #[document_parameters(
385 "The bitraversable structure to traverse.",
386 "The function for first-position elements.",
387 "The function for second-position elements."
388 )]
389 #[document_returns("The transformed structure wrapped in the applicative context.")]
391 #[document_examples]
392 pub fn bi_for<
408 'a,
409 Brand: Bitraversable,
410 A: 'a + Clone,
411 B: 'a + Clone,
412 C: 'a + Clone,
413 D: 'a + Clone,
414 F: Applicative,
415 >(
416 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
417 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
418 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
419 ) -> 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>)>)
420 {
421 Brand::bi_traverse::<A, B, C, D, F>(f, g, p)
422 }
423
424 #[document_signature]
428 #[document_type_parameters(
430 "The lifetime of the values.",
431 "The brand of the bitraversable structure.",
432 "The type of the first-position elements.",
433 "The type of the second-position elements (unchanged).",
434 "The output type for first-position elements.",
435 "The applicative context."
436 )]
437 #[document_parameters(
439 "The bitraversable structure to traverse.",
440 "The function for first-position elements."
441 )]
442 #[document_returns("The transformed structure wrapped in the applicative context.")]
444 #[document_examples]
445 pub fn for_left<
457 'a,
458 Brand: Bitraversable,
459 A: 'a + Clone,
460 B: 'a + Clone,
461 C: 'a + Clone,
462 F: Applicative,
463 >(
464 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
465 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
466 ) -> 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>)>)
467 {
468 Brand::bi_traverse::<A, B, C, B, F>(f, |b| F::pure(b), p)
469 }
470
471 #[document_signature]
475 #[document_type_parameters(
477 "The lifetime of the values.",
478 "The brand of the bitraversable structure.",
479 "The type of the first-position elements (unchanged).",
480 "The type of the second-position elements.",
481 "The output type for second-position elements.",
482 "The applicative context."
483 )]
484 #[document_parameters(
486 "The bitraversable structure to traverse.",
487 "The function for second-position elements."
488 )]
489 #[document_returns("The transformed structure wrapped in the applicative context.")]
491 #[document_examples]
492 pub fn for_right<
504 'a,
505 Brand: Bitraversable,
506 A: 'a + Clone,
507 B: 'a + Clone,
508 D: 'a + Clone,
509 F: Applicative,
510 >(
511 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
512 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
513 ) -> 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>)>)
514 {
515 Brand::bi_traverse::<A, B, A, D, F>(|a| F::pure(a), g, p)
516 }
517}
518
519pub use inner::*;