blob: 0d093cb52acb08a1d7c5e9bf4ea86bf936cd9f67 (
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
|
use crate::typecheck::TypeError;
use dhall_core::*;
pub struct Parsed(SubExpr<X, Import>);
pub struct Resolved(SubExpr<X, X>);
pub struct Typed(SubExpr<X, X>, Type);
pub struct Type(Box<Normalized>);
pub struct Normalized(SubExpr<X, X>);
// impl Parsed {
// pub fn resolve(self) -> Result<Resolved, ImportError> {
// Ok(Resolved(crate::imports::resolve(self.0)?))
// }
// }
impl Resolved {
pub fn typecheck(self) -> Result<Typed, TypeError<X>> {
let typ = Type(Box::new(Normalized(crate::typecheck::type_of(
self.0.clone(),
)?)));
Ok(Typed(self.0, typ))
}
}
impl Typed {
pub fn normalize(self) -> Normalized {
Normalized(crate::normalize::normalize(self.0))
}
pub fn get_type(&self) -> &Type {
&self.1
}
}
impl Type {
pub fn as_expr(&self) -> &Normalized {
&*self.0
}
}
|