summaryrefslogtreecommitdiff
path: root/dhall/src/normalize.rs
diff options
context:
space:
mode:
authorNadrieril2019-04-07 18:04:45 +0200
committerNadrieril2019-04-07 18:04:45 +0200
commit21b1fda39e51d157dadbfbb2aeb0f542a9506fcf (patch)
tree09012b2d9294a58455b74e8bd0e041f7cb153a23 /dhall/src/normalize.rs
parent727c5219c9af55df3e61fb372fa2fadecdd15b18 (diff)
parent4bebcd96b6e76b9b8ae7877af91d2ae571e617a9 (diff)
Merge branch 'statemachine-api'
Diffstat (limited to 'dhall/src/normalize.rs')
-rw-r--r--dhall/src/normalize.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs
index 24a8601..c07d3cb 100644
--- a/dhall/src/normalize.rs
+++ b/dhall/src/normalize.rs
@@ -1,8 +1,19 @@
#![allow(non_snake_case)]
+use crate::expr::*;
use dhall_core::*;
use dhall_generator::dhall_expr;
use std::fmt;
+impl Typed {
+ pub fn normalize(self) -> Normalized {
+ Normalized(normalize(self.0), self.1)
+ }
+ /// Pretends this expression is normalized. Use with care.
+ pub fn skip_normalize(self) -> Normalized {
+ Normalized(self.0, self.1)
+ }
+}
+
fn apply_builtin<S, A>(b: Builtin, args: &Vec<Expr<S, A>>) -> WhatNext<S, A>
where
S: fmt::Debug + Clone,
@@ -202,7 +213,7 @@ enum WhatNext<'a, S, A> {
DoneAsIs,
}
-pub fn normalize_ref<S, A>(expr: &Expr<S, A>) -> Expr<S, A>
+fn normalize_ref<S, A>(expr: &Expr<S, A>) -> Expr<S, A>
where
S: fmt::Debug + Clone,
A: fmt::Debug + Clone,
@@ -306,7 +317,7 @@ where
/// However, `normalize` will not fail if the expression is ill-typed and will
/// leave ill-typed sub-expressions unevaluated.
///
-pub fn normalize<S, A>(e: SubExpr<S, A>) -> SubExpr<S, A>
+fn normalize<S, A>(e: SubExpr<S, A>) -> SubExpr<S, A>
where
S: fmt::Debug + Clone,
A: fmt::Debug + Clone,