#![allow(non_snake_case)] use std::borrow::Borrow; use std::borrow::Cow; use std::collections::BTreeMap; use std::fmt; use crate::expr::*; use crate::normalize::{NormalizationContext, Thunk, TypeThunk, Value}; use crate::traits::DynamicType; use dhall_proc_macros as dhall; use dhall_syntax; use dhall_syntax::context::Context; use dhall_syntax::*; use self::TypeMessage::*; type InputSubExpr = SubExpr; type OutputSubExpr = SubExpr; impl Resolved { pub fn typecheck(self) -> Result { type_of(self.0) } pub fn typecheck_with(self, ty: &Type) -> Result { let expr = self.0; let ty = ty.to_expr().embed_absurd().note_absurd(); type_of(expr.rewrap(ExprF::Annot(expr.clone(), ty))) } /// Pretends this expression has been typechecked. Use with care. #[allow(dead_code)] pub fn skip_typecheck(self) -> Typed { Typed::from_thunk_untyped(Thunk::new( NormalizationContext::new(), self.0, )) } } impl Typed { fn to_type(&self) -> Type { match &self.to_value() { Value::Const(c) => Type(TypeInternal::Const(*c)), _ => Type(TypeInternal::Typed(Box::new(self.clone()))), } } } impl Normalized { fn shift(&self, delta: isize, var: &Var