summaryrefslogtreecommitdiff
path: root/dhall_normalize
diff options
context:
space:
mode:
Diffstat (limited to 'dhall_normalize')
-rw-r--r--dhall_normalize/Cargo.toml1
-rw-r--r--dhall_normalize/src/lib.rs1
-rw-r--r--dhall_normalize/src/normalize.rs10
3 files changed, 7 insertions, 5 deletions
diff --git a/dhall_normalize/Cargo.toml b/dhall_normalize/Cargo.toml
index 3affee8..ad1cc0d 100644
--- a/dhall_normalize/Cargo.toml
+++ b/dhall_normalize/Cargo.toml
@@ -15,3 +15,4 @@ nom = "3.0.0"
term-painter = "0.2.3"
pest = { git = "https://github.com/pest-parser/pest" }
dhall_core = { path = "../dhall_core" }
+dhall_generator = { path = "../dhall_generator" }
diff --git a/dhall_normalize/src/lib.rs b/dhall_normalize/src/lib.rs
index a2f7041..df49146 100644
--- a/dhall_normalize/src/lib.rs
+++ b/dhall_normalize/src/lib.rs
@@ -1,5 +1,6 @@
#![feature(box_patterns)]
#![feature(trace_macros)]
+#![feature(proc_macro_hygiene)]
mod normalize;
pub use crate::normalize::*;
diff --git a/dhall_normalize/src/normalize.rs b/dhall_normalize/src/normalize.rs
index 1fa5524..3b87419 100644
--- a/dhall_normalize/src/normalize.rs
+++ b/dhall_normalize/src/normalize.rs
@@ -1,6 +1,7 @@
#![allow(non_snake_case)]
use std::fmt;
use dhall_core::core::*;
+use dhall_generator::dhall;
/// Reduce an expression to its normal form, performing beta reduction
///
@@ -158,11 +159,10 @@ where
normalize(&b)
}
(App(box Builtin(OptionalBuild), a0), g) => {
- let e2: Expr<_, _> = app(app(app(g,
- App(bx(Builtin(Optional)), a0.clone())),
- Lam("x", a0.clone(),
- bx(OptionalLit(Some(a0.clone()), vec![Var(V("x", 0))])))),
- OptionalLit(Some(a0), vec![]));
+ let x = bx(Var(V("x", 0)));
+ let g = bx(g);
+ let e2: Expr<_, _> =
+ dhall!((g (Optional a0)) (λ(x: a0) -> [x] : Optional a0) ([] : Optional a0));
normalize(&e2)
}
(f2, a2) => app(f2, a2),