#![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_syntax; use dhall_syntax::context::Context; use dhall_syntax::*; use dhall_generator as dhall; use self::TypeMessage::*; impl<'a> Resolved<'a> { pub fn typecheck(self) -> Result, TypeError> { type_of(self.0.unnote()) } pub fn typecheck_with( self, ty: &Type, ) -> Result, TypeError> { 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<'a> { Typed::from_thunk_untyped(Thunk::new( NormalizationContext::new(), self.0.unnote(), )) } } impl<'a> Typed<'a> { fn to_type(&self) -> Type<'a> { match &self.to_value() { Value::Const(c) => Type(TypeInternal::Const(*c)), _ => Type(TypeInternal::Typed(Box::new(self.clone()))), } } } impl<'a> Normalized<'a> { fn shift(&self, delta: isize, var: &V