summaryrefslogtreecommitdiff
path: root/dhall/src/expr.rs
diff options
context:
space:
mode:
authorNadrieril2019-04-06 18:24:49 +0200
committerNadrieril2019-04-06 18:24:49 +0200
commit366bc783e62682c9597e8caba1dac56638d34fa9 (patch)
treecf6aa89b0126cba5198fd9c4abf4d668caac8517 /dhall/src/expr.rs
parent42d0f8100462f8a17a3ba1b86664310cdb71dfdc (diff)
Define some newtypes for Expr
Closes #50
Diffstat (limited to 'dhall/src/expr.rs')
-rw-r--r--dhall/src/expr.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs
new file mode 100644
index 0000000..0d093cb
--- /dev/null
+++ b/dhall/src/expr.rs
@@ -0,0 +1,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
+ }
+}