#![allow(non_snake_case)] use std::fmt; use crate::expr::*; use dhall_core; use dhall_core::context::Context; use dhall_core::*; use dhall_generator as dhall; use self::TypeMessage::*; impl Resolved { pub fn typecheck(self) -> Result> { let typ = crate::typecheck::type_of_(self.0.clone())?; Ok(typ) } } impl Typed { fn as_expr(&self) -> &SubExpr { &self.0 } fn into_expr(self) -> SubExpr { self.0 } pub fn into_type(self) -> Type { self.1 } pub fn get_type(&self) -> &Type { &self.1 } } impl Normalized { fn as_expr(&self) -> &SubExpr { &self.0 } fn into_expr(self) -> SubExpr { self.0 } pub fn get_type(&self) -> &Type { &self.1 } fn into_type(self) -> Type { crate::expr::Type(TypeInternal::Expr(Box::new(self))) } } impl Type { fn as_expr(&self) -> &SubExpr { &self.as_normalized().as_expr() } fn as_normalized(&self) -> &Normalized { use TypeInternal::*; match &self.0 { Expr(e) => &e, Universe(_) => unimplemented!(), } } fn into_expr(self) -> SubExpr { use TypeInternal::*; match self.0 { Expr(e) => e.into_expr(), Universe(_) => unimplemented!(), } } pub fn get_type(&self) -> &Type { use TypeInternal::*; match &self.0 { Expr(e) => e.get_type(), Universe(_) => unimplemented!(), // Universe(n) => &Type(Universe(n+1)), } } } const TYPE_OF_SORT: Type = Type(TypeInternal::Universe(4)); fn rule(a: Const, b: Const) -> Result { use dhall_core::Const::*; match (a, b) { (_, Type) => Ok(Type), (Kind, Kind) => Ok(Kind), (Sort, Sort) => Ok(Sort), (Sort, Kind) => Ok(Sort), _ => Err(()), } } fn match_vars(vl: &V