diff options
author | Nadrieril | 2019-03-18 00:21:41 +0100 |
---|---|---|
committer | Nadrieril | 2019-03-18 00:21:41 +0100 |
commit | f112145814ed8243904d97c92a15bbdb7053d1a0 (patch) | |
tree | 0e858a2d807f9622a90ae84b94ca1a11ff9e4b82 /dhall/src/normalize.rs | |
parent | 2ec0dc3f470be85a093caf1ebaa8898576c8c478 (diff) |
Considerably simplify subst, shift and typechecking
Diffstat (limited to '')
-rw-r--r-- | dhall/src/normalize.rs | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index af30e3b..8438670 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -163,10 +163,9 @@ where let just = Rc::clone(&args[3]); return normalize_whnf(&dhall_expr!(just x)); } - ( - OptionalFold, - [_, OptionalLit(_, None), _, _, _], - ) => return Rc::clone(&args[4]), + (OptionalFold, [_, OptionalLit(_, None), _, _, _]) => { + return Rc::clone(&args[4]) + } // // fold/build fusion // (OptionalFold, [_, App(box Builtin(OptionalBuild), [_, x, rest..]), rest..]) => { // normalize_whnf(&App(bx(x.clone()), rest.to_vec())) @@ -237,9 +236,7 @@ where NaturalLit(x * y) } // TODO: interpolation - (TextAppend, TextLit(x), TextLit(y)) => { - TextLit(x + y) - } + (TextAppend, TextLit(x), TextLit(y)) => TextLit(x + y), (ListAppend, ListLit(t1, xs), ListLit(t2, ys)) => { let t1: Option<Rc<_>> = t1.as_ref().map(Rc::clone); let t2: Option<Rc<_>> = t2.as_ref().map(Rc::clone); @@ -279,16 +276,10 @@ where /// However, `normalize` will not fail if the expression is ill-typed and will /// leave ill-typed sub-expressions unevaluated. /// -pub fn normalize<S, T, A>(e: SubExpr<S, A>) -> SubExpr<T, A> +pub fn normalize<S, A>(e: SubExpr<S, A>) -> SubExpr<S, A> where - S: Clone + fmt::Debug, - T: Clone + fmt::Debug, - A: Clone + fmt::Debug, + S: fmt::Debug, + A: fmt::Debug, { - rc(normalize_whnf(&e).map_shallow_rc( - |x| normalize(Rc::clone(x)), - |_| unreachable!(), - |x| x.clone(), - |x| x.clone(), - )) + map_subexpr_rc(&normalize_whnf(&e), |x| normalize(Rc::clone(x))) } |