From aec80599f161096b68cac88ffb8852a61b62fcfa Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 19 Jan 2020 18:30:13 +0000 Subject: Restore more types in value_to_tyexpr --- dhall/src/semantics/tck/mod.rs | 2 ++ dhall/src/semantics/tck/tyexpr.rs | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'dhall/src/semantics/tck') diff --git a/dhall/src/semantics/tck/mod.rs b/dhall/src/semantics/tck/mod.rs index 407605d..ba95847 100644 --- a/dhall/src/semantics/tck/mod.rs +++ b/dhall/src/semantics/tck/mod.rs @@ -1,2 +1,4 @@ +pub mod context; pub mod tyexpr; +pub mod typecheck; pub(crate) use tyexpr::*; diff --git a/dhall/src/semantics/tck/tyexpr.rs b/dhall/src/semantics/tck/tyexpr.rs index f0fcdd1..36cae04 100644 --- a/dhall/src/semantics/tck/tyexpr.rs +++ b/dhall/src/semantics/tck/tyexpr.rs @@ -1,4 +1,6 @@ #![allow(dead_code)] +use crate::error::{TypeError, TypeMessage}; +use crate::semantics::core::context::TyCtx; use crate::semantics::core::var::AlphaVar; use crate::semantics::phase::typecheck::rc; use crate::semantics::phase::Normalized; @@ -33,11 +35,21 @@ impl TyExpr { pub fn kind(&self) -> &TyExprKind { &*self.kind } + pub fn get_type(&self) -> Result { + match &self.ty { + Some(t) => Ok(t.clone()), + None => Err(TypeError::new(&TyCtx::new(), TypeMessage::Sort)), + } + } /// Converts a value back to the corresponding AST expression. - pub fn to_expr<'a>(&'a self, opts: ToExprOptions) -> NormalizedExpr { + pub fn to_expr(&self, opts: ToExprOptions) -> NormalizedExpr { tyexpr_to_expr(self, opts, &mut Vec::new()) } + // TODO: temporary hack + pub fn to_value(&self) -> Value { + todo!() + } } fn tyexpr_to_expr<'a>( -- cgit v1.2.3