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
|
use crate::imports::ImportRoot;
use dhall_core::*;
macro_rules! derive_other_traits {
($ty:ident) => {
impl std::cmp::PartialEq for $ty {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl std::fmt::Display for $ty {
fn fmt(
&self,
f: &mut std::fmt::Formatter,
) -> Result<(), std::fmt::Error> {
self.0.fmt(f)
}
}
};
}
#[derive(Debug, Clone, Eq)]
pub struct Parsed(pub(crate) SubExpr<X, Import>, pub(crate) ImportRoot);
derive_other_traits!(Parsed);
#[derive(Debug, Clone, Eq)]
pub struct Resolved(pub(crate) SubExpr<X, X>);
derive_other_traits!(Resolved);
#[derive(Debug, Clone, Eq)]
pub struct Typed(pub(crate) SubExpr<X, X>, pub(crate) Type);
derive_other_traits!(Typed);
#[derive(Debug, Clone, Eq)]
pub struct Normalized(pub(crate) SubExpr<X, X>, pub(crate) Type);
derive_other_traits!(Normalized);
/// An expression of type `Type` (like `Bool` or `Natural -> Text`, but not `Type`)
#[derive(Debug, Clone, Eq)]
pub struct SimpleType(pub(crate) SubExpr<X, X>);
derive_other_traits!(SimpleType);
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Type(pub(crate) TypeInternal);
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum TypeInternal {
Expr(Box<Normalized>),
Untyped,
}
// Exposed for the macros
#[doc(hidden)]
impl From<SimpleType> for SubExpr<X, X> {
fn from(x: SimpleType) -> SubExpr<X, X> {
x.0
}
}
// Exposed for the macros
#[doc(hidden)]
impl From<SubExpr<X, X>> for SimpleType {
fn from(x: SubExpr<X, X>) -> SimpleType {
SimpleType(x)
}
}
|