#![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::*; impl Resolved { pub fn typecheck(self) -> Result { type_of(self.0.unnote()) } pub fn typecheck_with(self, ty: &Type) -> Result { let expr: SubExpr<_, _> = self.0.unnote(); let ty: SubExpr<_, _> = ty.to_expr().embed_absurd(); type_of(rc(ExprF::Annot(expr, 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.unnote(), )) } } 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: &V