#![allow(non_snake_case)] use std::collections::BTreeMap; use std::rc::Rc; use dhall_syntax::context::Context; use dhall_syntax::{ rc, BinOp, Builtin, Const, ExprF, Integer, InterpolatedText, InterpolatedTextContents, Label, Natural, SubExpr, V, X, }; use dhall_generator as dhall; use crate::expr::{Normalized, Type, Typed, TypedInternal}; type InputSubExpr = SubExpr>; type OutputSubExpr = SubExpr; impl<'a> Typed<'a> { /// Reduce an expression to its normal form, performing beta reduction /// /// `normalize` does not type-check the expression. You may want to type-check /// expressions before normalizing them since normalization can convert an /// ill-typed expression into a well-typed expression. /// /// However, `normalize` will not fail if the expression is ill-typed and will /// leave ill-typed sub-expressions unevaluated. /// pub fn normalize(self) -> Normalized<'a> { let internal = match self.0 { TypedInternal::Sort => TypedInternal::Sort, TypedInternal::Value(thunk, t) => { // TODO: stupid but needed for now let thunk = Thunk::from_normalized_expr(thunk.normalize_to_expr()); thunk.normalize_nf(); TypedInternal::Value(thunk, t) } }; Normalized(internal, self.1) } pub(crate) fn shift(&self, delta: isize, var: &V