diff options
author | Nadrieril | 2020-02-13 20:17:41 +0000 |
---|---|---|
committer | Nadrieril | 2020-02-13 20:17:41 +0000 |
commit | f29a40fb55b898b3a3cc51f198e8522eaecf0777 (patch) | |
tree | ba31bed1f166c8fc0f448b477548cceeb5e4f8ef /dhall/src/semantics/tck/tyexpr.rs | |
parent | 7b649b8647c60f1c02050805520f307edff0a94f (diff) |
Simplify conversions to/from TyExpr
Diffstat (limited to '')
-rw-r--r-- | dhall/src/semantics/tck/tyexpr.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/dhall/src/semantics/tck/tyexpr.rs b/dhall/src/semantics/tck/tyexpr.rs index b49ea3e..dc14cd2 100644 --- a/dhall/src/semantics/tck/tyexpr.rs +++ b/dhall/src/semantics/tck/tyexpr.rs @@ -1,6 +1,6 @@ use crate::error::{TypeError, TypeMessage}; -use crate::semantics::{Hir, HirKind, NzEnv, Value,TyEnv}; -use crate::syntax::Span; +use crate::semantics::{Hir, HirKind, NzEnv, TyEnv, Value}; +use crate::syntax::{Const, Span}; use crate::{NormalizedExpr, ToExprOptions}; pub(crate) type Type = Value; @@ -33,7 +33,12 @@ impl TyExpr { } } pub fn get_type_tyexpr(&self, env: &TyEnv) -> Result<TyExpr, TypeError> { - Ok(self.get_type()?.to_tyexpr_tyenv(env)) + Ok(self.get_type()?.to_hir(env.as_varenv()).typecheck(env)?) + } + /// Get the kind (the type of the type) of this value + // TODO: avoid recomputing so much + pub fn get_kind(&self, env: &TyEnv) -> Result<Option<Const>, TypeError> { + Ok(self.get_type_tyexpr(env)?.get_type()?.as_const()) } pub fn to_hir(&self) -> Hir { |