1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use core::marker::PhantomData;

use serde::{
  Deserialize,
  Serialize,
};

use super::traits::*;
use crate::internal::functional::type_app::*;

#[derive(Copy, Clone, Serialize, Deserialize)]
pub enum Bottom {}

#[derive(Copy, Clone, Serialize, Deserialize)]
pub enum Sum<A, B>
{
  Inl(A),
  Inr(B),
}

pub struct AppSum<'a, Row, F>
{
  pub row: Box<dyn HasSumApp<'a, Row, F> + 'a>,
}

pub struct ChoiceSelector<N>
{
  phantom: PhantomData<N>,
}

impl<'a, Row, F> AppSum<'a, Row, F>
where
  F: TyCon,
  Row: SumApp<'a, F>,
{
  pub fn new(row: Row::Applied) -> AppSum<'a, Row, F>
  where
    F: TyCon,
    Row: SumApp<'a, F>,
    Row::Applied: Send,
  {
    AppSum { row: Box::new(row) }
  }

  pub fn get_sum(self) -> Row::Applied
  {
    *self.row.get_sum()
  }
}

impl<N> ChoiceSelector<N>
{
  pub const fn new() -> ChoiceSelector<N>
  {
    ChoiceSelector {
      phantom: PhantomData,
    }
  }
}