use std::borrow::Cow; use std::rc::Rc; use dhall_syntax::context::Context; use dhall_syntax::{Label, V}; use crate::core::thunk::Thunk; use crate::core::value::Value; use crate::core::var::{AlphaVar, Shift, Subst}; use crate::phase::{Normalized, Type, Typed}; #[derive(Debug, Clone)] enum NzEnvItem { Thunk(Thunk), Skip(AlphaVar), } #[derive(Debug, Clone)] pub(crate) struct NormalizationContext(Rc>); #[derive(Debug, Clone)] pub(crate) enum TyEnvItem { Type(AlphaVar, Type), Value(Normalized), } #[derive(Debug, Clone)] pub(crate) struct TypecheckContext(pub(crate) Context); impl NormalizationContext { pub(crate) fn new() -> Self { NormalizationContext(Rc::new(Context::new())) } pub(crate) fn skip(&self, x: &Label) -> Self { NormalizationContext(Rc::new( self.0 .map(|_, e| e.shift(1, &x.into())) .insert(x.clone(), NzEnvItem::Skip(x.into())), )) } pub(crate) fn lookup(&self, var: &V