1#[fp_macros::document_module]
21mod inner {
22 use {
23 crate::{
24 classes::*,
25 functions::*,
26 kinds::*,
27 },
28 fp_macros::*,
29 };
30
31 #[document_examples]
49 pub trait Bitraversable: Bifunctor + Bifoldable {
79 #[document_signature]
84 #[document_type_parameters(
86 "The lifetime of the values.",
87 "The type of the first-position elements.",
88 "The type of the second-position elements.",
89 "The output type for first-position elements.",
90 "The output type for second-position elements.",
91 "The applicative context."
92 )]
93 #[document_parameters(
95 "The function for first-position elements.",
96 "The function for second-position elements.",
97 "The bitraversable structure to traverse."
98 )]
99 #[document_returns("The transformed structure wrapped in the applicative context.")]
101 #[document_examples]
102 fn bi_traverse<
118 'a,
119 A: 'a + Clone,
120 B: 'a + Clone,
121 C: 'a + Clone,
122 D: 'a + Clone,
123 F: Applicative,
124 >(
125 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
126 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
127 p: Apply!(<Self as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
128 ) -> 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>)>);
129
130 #[document_signature]
135 #[document_type_parameters(
137 "The lifetime of the values.",
138 "The type of the first-position elements.",
139 "The type of the second-position elements.",
140 "The applicative context."
141 )]
142 #[document_parameters("The bitraversable structure containing applicative values.")]
144 #[document_returns("The applicative context wrapping the bitraversable structure.")]
146 #[document_examples]
147 fn bi_sequence<'a, A: 'a + Clone, B: 'a + Clone, F: Applicative>(
159 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>)>)
160 ) -> 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>)>)
161 where
162 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>): Clone,
163 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone, {
164 Self::bi_traverse::<
165 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>),
166 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>),
167 A,
168 B,
169 F,
170 >(identity, identity, ta)
171 }
172 }
173
174 #[document_signature]
178 #[document_type_parameters(
180 "The lifetime of the values.",
181 "The brand of the bitraversable structure.",
182 "The type of the first-position elements.",
183 "The type of the second-position elements.",
184 "The output type for first-position elements.",
185 "The output type for second-position elements.",
186 "The applicative context."
187 )]
188 #[document_parameters(
190 "The function for first-position elements.",
191 "The function for second-position elements.",
192 "The bitraversable structure to traverse."
193 )]
194 #[document_returns("The transformed structure wrapped in the applicative context.")]
196 #[document_examples]
197 pub fn bi_traverse<
213 'a,
214 Brand: Bitraversable,
215 A: 'a + Clone,
216 B: 'a + Clone,
217 C: 'a + Clone,
218 D: 'a + Clone,
219 F: Applicative,
220 >(
221 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
222 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
223 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
224 ) -> 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>)>)
225 {
226 Brand::bi_traverse::<A, B, C, D, F>(f, g, p)
227 }
228
229 #[document_signature]
233 #[document_type_parameters(
235 "The lifetime of the values.",
236 "The brand of the bitraversable structure.",
237 "The type of the first-position elements.",
238 "The type of the second-position elements.",
239 "The applicative context."
240 )]
241 #[document_parameters("The bitraversable structure containing applicative values.")]
243 #[document_returns("The applicative context wrapping the bitraversable structure.")]
245 #[document_examples]
246 pub fn bi_sequence<'a, Brand: Bitraversable, A: 'a + Clone, B: 'a + Clone, F: Applicative>(
258 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>)>)
259 ) -> 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>)>)
260 where
261 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, A>): Clone,
262 Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, B>): Clone, {
263 Brand::bi_sequence::<A, B, F>(ta)
264 }
265
266 #[document_signature]
270 #[document_type_parameters(
272 "The lifetime of the values.",
273 "The brand of the bitraversable structure.",
274 "The type of the first-position elements.",
275 "The type of the second-position elements (unchanged).",
276 "The output type for first-position elements.",
277 "The applicative context."
278 )]
279 #[document_parameters(
281 "The function for first-position elements.",
282 "The bitraversable structure to traverse."
283 )]
284 #[document_returns("The transformed structure wrapped in the applicative context.")]
286 #[document_examples]
287 pub fn traverse_left<
299 'a,
300 Brand: Bitraversable,
301 A: 'a + Clone,
302 B: 'a + Clone,
303 C: 'a + Clone,
304 F: Applicative,
305 >(
306 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
307 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
308 ) -> 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>)>)
309 {
310 Brand::bi_traverse::<A, B, C, B, F>(f, |b| F::pure(b), p)
311 }
312
313 #[document_signature]
317 #[document_type_parameters(
319 "The lifetime of the values.",
320 "The brand of the bitraversable structure.",
321 "The type of the first-position elements (unchanged).",
322 "The type of the second-position elements.",
323 "The output type for second-position elements.",
324 "The applicative context."
325 )]
326 #[document_parameters(
328 "The function for second-position elements.",
329 "The bitraversable structure to traverse."
330 )]
331 #[document_returns("The transformed structure wrapped in the applicative context.")]
333 #[document_examples]
334 pub fn traverse_right<
346 'a,
347 Brand: Bitraversable,
348 A: 'a + Clone,
349 B: 'a + Clone,
350 D: 'a + Clone,
351 F: Applicative,
352 >(
353 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
354 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
355 ) -> 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>)>)
356 {
357 Brand::bi_traverse::<A, B, A, D, F>(|a| F::pure(a), g, p)
358 }
359
360 #[document_signature]
364 #[document_type_parameters(
366 "The lifetime of the values.",
367 "The brand of the bitraversable structure.",
368 "The type of the first-position elements.",
369 "The type of the second-position elements.",
370 "The output type for first-position elements.",
371 "The output type for second-position elements.",
372 "The applicative context."
373 )]
374 #[document_parameters(
376 "The bitraversable structure to traverse.",
377 "The function for first-position elements.",
378 "The function for second-position elements."
379 )]
380 #[document_returns("The transformed structure wrapped in the applicative context.")]
382 #[document_examples]
383 pub fn bi_for<
399 'a,
400 Brand: Bitraversable,
401 A: 'a + Clone,
402 B: 'a + Clone,
403 C: 'a + Clone,
404 D: 'a + Clone,
405 F: Applicative,
406 >(
407 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
408 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
409 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
410 ) -> 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>)>)
411 {
412 Brand::bi_traverse::<A, B, C, D, F>(f, g, p)
413 }
414
415 #[document_signature]
419 #[document_type_parameters(
421 "The lifetime of the values.",
422 "The brand of the bitraversable structure.",
423 "The type of the first-position elements.",
424 "The type of the second-position elements (unchanged).",
425 "The output type for first-position elements.",
426 "The applicative context."
427 )]
428 #[document_parameters(
430 "The bitraversable structure to traverse.",
431 "The function for first-position elements."
432 )]
433 #[document_returns("The transformed structure wrapped in the applicative context.")]
435 #[document_examples]
436 pub fn for_left<
448 'a,
449 Brand: Bitraversable,
450 A: 'a + Clone,
451 B: 'a + Clone,
452 C: 'a + Clone,
453 F: Applicative,
454 >(
455 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
456 f: impl Fn(A) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, C>) + 'a,
457 ) -> 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>)>)
458 {
459 Brand::bi_traverse::<A, B, C, B, F>(f, |b| F::pure(b), p)
460 }
461
462 #[document_signature]
466 #[document_type_parameters(
468 "The lifetime of the values.",
469 "The brand of the bitraversable structure.",
470 "The type of the first-position elements (unchanged).",
471 "The type of the second-position elements.",
472 "The output type for second-position elements.",
473 "The applicative context."
474 )]
475 #[document_parameters(
477 "The bitraversable structure to traverse.",
478 "The function for second-position elements."
479 )]
480 #[document_returns("The transformed structure wrapped in the applicative context.")]
482 #[document_examples]
483 pub fn for_right<
495 'a,
496 Brand: Bitraversable,
497 A: 'a + Clone,
498 B: 'a + Clone,
499 D: 'a + Clone,
500 F: Applicative,
501 >(
502 p: Apply!(<Brand as Kind!( type Of<'a, A: 'a, B: 'a>: 'a; )>::Of<'a, A, B>),
503 g: impl Fn(B) -> Apply!(<F as Kind!( type Of<'a, T: 'a>: 'a; )>::Of<'a, D>) + 'a,
504 ) -> 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>)>)
505 {
506 Brand::bi_traverse::<A, B, A, D, F>(|a| F::pure(a), g, p)
507 }
508}
509
510pub use inner::*;