summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/tck/tyexpr.rs
diff options
context:
space:
mode:
authorNadrieril2020-01-29 22:06:01 +0000
committerNadrieril2020-01-29 22:06:01 +0000
commita928c3c4f51d87fd942e8a81727962c00abf6808 (patch)
tree4351f1326814d7ba5ecd89d47a56c9f55be40fb5 /dhall/src/semantics/tck/tyexpr.rs
parent489174a426e6057a68b6edd2e9b4387d09912a25 (diff)
Cleanup variable handling
Diffstat (limited to '')
-rw-r--r--dhall/src/semantics/tck/tyexpr.rs26
1 files changed, 20 insertions, 6 deletions
diff --git a/dhall/src/semantics/tck/tyexpr.rs b/dhall/src/semantics/tck/tyexpr.rs
index 262cda6..114bb14 100644
--- a/dhall/src/semantics/tck/tyexpr.rs
+++ b/dhall/src/semantics/tck/tyexpr.rs
@@ -1,5 +1,4 @@
use crate::error::{TypeError, TypeMessage};
-use crate::semantics::core::var::AlphaVar;
use crate::semantics::phase::normalize::normalize_tyexpr_whnf;
use crate::semantics::phase::typecheck::rc;
use crate::semantics::phase::Normalized;
@@ -9,6 +8,19 @@ use crate::syntax::{ExprKind, Span, V};
pub(crate) type Type = Value;
+/// Stores an alpha-normalized variable.
+#[derive(Debug, Clone, Copy)]
+pub struct AlphaVar {
+ idx: usize,
+}
+
+#[derive(Debug, Clone)]
+pub(crate) enum TyExprKind {
+ Var(AlphaVar),
+ // Forbidden ExprKind variants: Var, Import, Embed
+ Expr(ExprKind<TyExpr, Normalized>),
+}
+
// An expression with inferred types at every node and resolved variables.
#[derive(Clone)]
pub(crate) struct TyExpr {
@@ -17,11 +29,13 @@ pub(crate) struct TyExpr {
span: Span,
}
-#[derive(Debug, Clone)]
-pub(crate) enum TyExprKind {
- Var(AlphaVar),
- // Forbidden ExprKind variants: Var, Import, Embed
- Expr(ExprKind<TyExpr, Normalized>),
+impl AlphaVar {
+ pub(crate) fn new(idx: usize) -> Self {
+ AlphaVar { idx }
+ }
+ pub(crate) fn idx(&self) -> usize {
+ self.idx
+ }
}
impl TyExpr {