From 54382cd107d1befd6015f8232716158a20db44a4 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 6 Mar 2019 23:35:39 +0100 Subject: Start parsing imports --- dhall/src/imports.rs | 11 +++++++++++ dhall/src/lib.rs | 2 +- dhall/src/main.rs | 4 +--- dhall/src/normalize.rs | 2 +- dhall/tests/tests.rs | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 dhall/src/imports.rs (limited to 'dhall') 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 { + +// } + +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"); -- cgit v1.2.3