#![allow(non_snake_case)] use std::collections::HashSet; 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 = Type(Box::new(Normalized(crate::typecheck::type_of( // self.0.clone(), // )?))); // Ok(Typed(self.0, typ)) let typ = crate::typecheck::type_of_(self.0.clone())?; Ok(typ) } } impl Typed { fn as_expr(&self) -> &SubExpr { &self.0 } pub fn get_type(&self) -> &Type { &self.1 } } impl Normalized { pub fn get_type(&self) -> &Type { &self.1 } fn into_type(self) -> Type { crate::expr::Type(TypeInternal::Expr(Box::new(self))) } } impl Type { // pub fn as_expr(&self) -> &Normalized { // &*self.0 // } fn as_expr(&self) -> &SubExpr { &self.as_normalized().0 } fn as_normalized(&self) -> &Normalized { use TypeInternal::*; match &self.0 { Expr(e) => &e, Universe(_) => unimplemented!(), } } pub fn get_type(&self) -> &Type { self.as_normalized().get_type() } } const TYPE_OF_SORT: crate::expr::Type = crate::expr::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