#![allow(non_snake_case)] use std::borrow::Borrow; use std::borrow::Cow; use std::collections::BTreeMap; use std::fmt; use std::marker::PhantomData; use crate::expr::*; use crate::normalize::{NormalizationContext, Thunk, TypeThunk, Value}; use crate::traits::DynamicType; use dhall_core; use dhall_core::context::Context; use dhall_core::*; 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.clone().unnote().embed()?; type_of(dhall::subexpr!(expr: ty)) } /// Pretends this expression has been typechecked. Use with care. #[allow(dead_code)] pub fn skip_typecheck(self) -> Typed<'a> { Typed( Thunk::new(NormalizationContext::new(), self.0.unnote()), None, PhantomData, ) } } impl<'a> Typed<'a> { fn get_type_move(self) -> Result, TypeError> { self.1.ok_or_else(|| { TypeError::new(&TypecheckContext::new(), TypeMessage::Untyped) }) } } impl<'a> Normalized<'a> { fn shift0(&self, delta: isize, label: &Label) -> Self { self.shift(delta, &V(label.clone(), 0)) } fn shift(&self, delta: isize, var: &V