ferrite_session/internal/functional/row/
traits.rs1use super::structs::*;
2use crate::internal::functional::{
3 base::*,
4 type_app::*,
5};
6
7pub trait RowCon: Sized {}
8
9pub trait ToRow
10{
11 type Row;
12}
13
14pub trait SumApp<'a, F>: RowCon
15where
16 F: TyCon,
17{
18 type Applied: Sized + Send + 'a;
19}
20
21pub trait FlattenSumApp<'a, F>: SumApp<'a, F>
23where
24 F: TyCon,
25{
26 type FlattenApplied;
27
28 fn unflatten_sum(row: Self::FlattenApplied) -> Self::Applied;
29
30 fn flatten_sum(row: AppSum<'a, Self, F>) -> Self::FlattenApplied;
31}
32
33pub trait HasSumApp<'a, Row, F>: Send
34{
35 fn get_sum(self: Box<Self>) -> Box<Row::Applied>
36 where
37 F: TyCon,
38 Row: SumApp<'a, F>;
39
40 fn get_sum_borrow<'b>(&'b self) -> &'b Row::Applied
41 where
42 F: TyCon,
43 Row: SumApp<'a, F>;
44}
45
46pub trait SumFunctor: RowCon
47{
48 fn lift_sum<'a, T: 'a, F1: 'a, F2: 'a>(
49 lift: T,
50 sum: AppSum<'a, Self, F1>,
51 ) -> AppSum<'a, Self, F2>
52 where
53 F1: TyCon,
54 F2: TyCon,
55 T: NaturalTransformation<'a, F1, F2>,
56 Self: 'a;
57}
58
59pub trait Prism<Row>
60where
61 Row: RowCon,
62{
63 type Elem;
64
65 fn inject_elem<'a, F: 'a + Send>(
66 elem: App<'a, F, Self::Elem>
67 ) -> AppSum<'a, Row, F>
68 where
69 F: TyCon,
70 Row: 'a;
71
72 fn extract_elem<'a, F: 'a + Send>(
73 row: AppSum<'a, Row, F>
74 ) -> Option<App<'a, F, Self::Elem>>
75 where
76 F: TyCon,
77 Row: 'a;
78}