From 77198a2833297289770867acdaf31db0e2011ea9 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 30 Apr 2019 15:35:13 +0200 Subject: Merge Typed and PartiallyNormalized --- dhall/src/expr.rs | 7 --- dhall/src/normalize.rs | 74 ++++++++++++-------------- dhall/src/typecheck.rs | 137 ++++++++++++++++++++++--------------------------- 3 files changed, 94 insertions(+), 124 deletions(-) (limited to 'dhall/src') diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs index c794324..1ddc4ba 100644 --- a/dhall/src/expr.rs +++ b/dhall/src/expr.rs @@ -43,13 +43,6 @@ pub(crate) struct Typed<'a>( pub(crate) PhantomData<&'a ()>, ); -#[derive(Debug, Clone)] -pub(crate) struct PartiallyNormalized<'a>( - pub(crate) crate::normalize::Value, - pub(crate) Option>, - pub(crate) PhantomData<&'a ()>, -); - #[derive(Debug, Clone)] pub(crate) struct Normalized<'a>( pub(crate) SubExpr, diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index 5151790..f15eea4 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -9,7 +9,7 @@ use dhall_core::{ }; use dhall_generator as dhall; -use crate::expr::{Normalized, PartiallyNormalized, Type, Typed}; +use crate::expr::{Normalized, Type, Typed}; type InputSubExpr = SubExpr>; type OutputSubExpr = SubExpr; @@ -25,37 +25,35 @@ impl<'a> Typed<'a> { /// leave ill-typed sub-expressions unevaluated. /// pub fn normalize(self) -> Normalized<'a> { - self.partially_normalize().normalize() + Normalized(self.0.as_whnf().normalize_to_expr(), self.1, self.2) } - pub(crate) fn partially_normalize(self) -> PartiallyNormalized<'a> { - PartiallyNormalized(self.0.as_whnf(), self.1, self.2) - } -} -impl<'a> PartiallyNormalized<'a> { - pub(crate) fn normalize(self) -> Normalized<'a> { - Normalized(self.0.normalize_to_expr(), self.1, self.2) - } pub(crate) fn shift(&self, delta: isize, var: &V