#![allow(non_snake_case)] use std::borrow::Borrow; use std::fmt; use std::marker::PhantomData; use crate::expr::*; 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.as_normalized()?.as_expr().absurd(); 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(self.0.unnote(), None, PhantomData) } } impl<'a> Typed<'a> { fn get_type_move(self) -> Result, TypeError> { self.1.ok_or(TypeError::new( &Context::new(), self.0, TypeMessage::Untyped, )) } } impl<'a> Normalized<'a> { // Expose the outermost constructor fn unroll_ref(&self) -> &Expr { self.as_expr().as_ref() } fn shift(&self, delta: isize, var: &V