diff options
author | Nadrieril | 2019-03-06 14:55:01 +0100 |
---|---|---|
committer | Nadrieril | 2019-03-06 14:55:01 +0100 |
commit | 45992d093b950170fc30e63d2c7d7a2767e9b9e8 (patch) | |
tree | 68bde8c8fe1ee6b4e577278a783e3f3b603b7e7f /dhall_normalize | |
parent | 8f944ae4622102ad66eff19434725087239c1950 (diff) |
Add proc_macro the generated dhall expressions
Diffstat (limited to 'dhall_normalize')
-rw-r--r-- | dhall_normalize/Cargo.toml | 1 | ||||
-rw-r--r-- | dhall_normalize/src/lib.rs | 1 | ||||
-rw-r--r-- | dhall_normalize/src/normalize.rs | 10 |
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), |