blob: 6b0e06e86073cb4c8f9605859016aaf04027cf30 (
plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
use dhall_core::*;
use dhall_generator::*;
#[derive(Debug, Clone)]
pub enum ConversionError {}
pub trait Type {
fn get_type() -> DhallExpr;
// fn as_dhall(&self) -> DhallExpr;
// fn from_dhall(e: DhallExpr) -> Result<Self, DhallConversionError>;
}
impl Type for bool {
fn get_type() -> DhallExpr {
dhall_expr!(Bool)
}
}
impl Type for Natural {
fn get_type() -> DhallExpr {
dhall_expr!(Natural)
}
}
impl Type for Integer {
fn get_type() -> DhallExpr {
dhall_expr!(Integer)
}
}
impl Type for String {
fn get_type() -> DhallExpr {
dhall_expr!(Text)
}
}
impl<A: Type, B: Type> Type for (A, B) {
fn get_type() -> DhallExpr {
let ta = A::get_type();
let tb = B::get_type();
dhall_expr!({ _1: ta, _2: tb })
}
}
impl<T: Type> Type for Option<T> {
fn get_type() -> DhallExpr {
let t = T::get_type();
dhall_expr!(Optional t)
}
}
impl<T: Type> Type for Vec<T> {
fn get_type() -> DhallExpr {
let t = T::get_type();
dhall_expr!(List t)
}
}
impl<'a, T: Type> Type for &'a T {
fn get_type() -> DhallExpr {
T::get_type()
}
}
impl<T> Type for std::marker::PhantomData<T> {
fn get_type() -> DhallExpr {
dhall_expr!({})
}
}
impl<T: Type, E: Type> Type for Result<T, E> {
fn get_type() -> DhallExpr {
let tt = T::get_type();
let te = E::get_type();
dhall_expr!(< Ok: tt | Err: te>)
}
}
|