summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall/src/expr.rs35
-rw-r--r--dhall/src/lib.rs10
2 files changed, 37 insertions, 8 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
+ }
+}
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index 7439312..fee5ba8 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -18,11 +18,5 @@ pub use crate::traits::*;
pub use dhall_generator::expr;
pub use dhall_generator::subexpr;
pub use dhall_generator::StaticType;
-
-// pub struct DhallExpr(dhall_core::DhallExpr);
-
-// impl DhallExpr {
-// pub fn normalize(self) -> Self {
-// DhallExpr(crate::normalize::normalize(self.0))
-// }
-// }
+pub mod expr;
+pub use crate::expr::*;