summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
authorNadrieril2019-03-06 23:35:39 +0100
committerNadrieril2019-03-06 23:35:39 +0100
commit54382cd107d1befd6015f8232716158a20db44a4 (patch)
tree81afc63e474ad58f384dde36550f9d50756c5217 /dhall/src
parent39fc0af2548127a7c2ee1345d4ea63d473e0ab5a (diff)
Start parsing imports
Diffstat (limited to '')
-rw-r--r--dhall/src/imports.rs11
-rw-r--r--dhall/src/lib.rs2
-rw-r--r--dhall/src/main.rs4
-rw-r--r--dhall/src/normalize.rs2
4 files changed, 14 insertions, 5 deletions
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs
new file mode 100644
index 0000000..32ddfd7
--- /dev/null
+++ b/dhall/src/imports.rs
@@ -0,0 +1,11 @@
+use dhall_core::{Expr, Import, ImportLocation, ImportMode, FilePrefix, X};
+
+
+// fn resolve_import(import: Import) -> Expr<X, Import> {
+
+// }
+
+pub fn resolve_imports<'i, S: Clone>(expr: &Expr<'i, S, Import>) -> Expr<'i, S, X> {
+ let no_import = |_: &Import| -> X { panic!("ahhh import") };
+ expr.map_embed(&no_import)
+}
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index 58b29a3..54f0983 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -5,4 +5,4 @@
mod normalize;
pub use crate::normalize::*;
pub mod typecheck;
-
+pub mod imports;
diff --git a/dhall/src/main.rs b/dhall/src/main.rs
index 3e8aca4..43d03ce 100644
--- a/dhall/src/main.rs
+++ b/dhall/src/main.rs
@@ -91,9 +91,7 @@ fn main() {
}
};
- /*
- expr' <- load expr
- */
+ let expr = imports::resolve_imports(&expr);
let type_expr = match typecheck::type_of(&expr) {
Err(e) => {
diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs
index ec594da..b46722a 100644
--- a/dhall/src/normalize.rs
+++ b/dhall/src/normalize.rs
@@ -145,7 +145,7 @@ where
},
// Normalize everything else before matching
- e => match e.map_shallow(normalize, |_| unreachable!()) {
+ e => match e.map_shallow(normalize, |_| unreachable!(), |x| x.clone()) {
BinOp(BoolAnd, box BoolLit(x), box BoolLit(y)) => BoolLit(x && y),
BinOp(BoolOr, box BoolLit(x), box BoolLit(y)) => BoolLit(x || y),
BinOp(BoolEQ, box BoolLit(x), box BoolLit(y)) => BoolLit(x == y),