summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2019-03-06 23:35:39 +0100
committerNadrieril2019-03-06 23:35:39 +0100
commit54382cd107d1befd6015f8232716158a20db44a4 (patch)
tree81afc63e474ad58f384dde36550f9d50756c5217 /dhall
parent39fc0af2548127a7c2ee1345d4ea63d473e0ab5a (diff)
Start parsing imports
Diffstat (limited to 'dhall')
-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
-rw-r--r--dhall/tests/tests.rs2
5 files changed, 15 insertions, 6 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),
diff --git a/dhall/tests/tests.rs b/dhall/tests/tests.rs
index a523b6e..8b910a2 100644
--- a/dhall/tests/tests.rs
+++ b/dhall/tests/tests.rs
@@ -14,7 +14,7 @@ make_spec_test!(normalization, spec_normalization_success_haskell_tutorial_acces
// make_spec_test!(normalization, spec_normalization_success_multiline_preserveComment, "normalization/success/multiline/preserveComment");
// make_spec_test!(normalization, spec_normalization_success_multiline_singleLine, "normalization/success/multiline/singleLine");
// make_spec_test!(normalization, spec_normalization_success_multiline_twoLines, "normalization/success/multiline/twoLines");
-// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "normalization/success/prelude/Bool/and/0");
+make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_0, "normalization/success/prelude/Bool/and/0");
// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_and_1, "normalization/success/prelude/Bool/and/1");
// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_build_0, "normalization/success/prelude/Bool/build/0");
// make_spec_test!(normalization, spec_normalization_success_prelude_Bool_build_1, "normalization/success/prelude/Bool/build/1");