summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/core
diff options
context:
space:
mode:
Diffstat (limited to 'dhall/src/semantics/core')
-rw-r--r--dhall/src/semantics/core/value.rs10
-rw-r--r--dhall/src/semantics/core/var.rs32
-rw-r--r--dhall/src/semantics/core/visitor.rs2
3 files changed, 6 insertions, 38 deletions
diff --git a/dhall/src/semantics/core/value.rs b/dhall/src/semantics/core/value.rs
index 7334552..918826b 100644
--- a/dhall/src/semantics/core/value.rs
+++ b/dhall/src/semantics/core/value.rs
@@ -3,7 +3,7 @@ use std::collections::HashMap;
use std::rc::Rc;
use crate::error::{TypeError, TypeMessage};
-use crate::semantics::core::var::{AlphaVar, Binder};
+use crate::semantics::core::var::Binder;
use crate::semantics::phase::normalize::{apply_any, normalize_whnf};
use crate::semantics::phase::typecheck::{
builtin_to_value, builtin_to_value_env, const_to_value,
@@ -83,7 +83,7 @@ pub(crate) enum ValueKind<Value> {
// Keep env around to construct Foo/build closures; hopefully temporary.
AppliedBuiltin(Builtin, Vec<Value>, Vec<Value>, NzEnv),
- Var(AlphaVar, NzVar),
+ Var(NzVar),
Const(Const),
BoolLit(bool),
NaturalLit(Natural),
@@ -258,9 +258,7 @@ impl Value {
pub fn to_tyexpr(&self, venv: VarEnv) -> TyExpr {
let tye = match &*self.as_kind() {
- // ValueKind::Var(v, _w) => TyExprKind::Var(*v),
- // TODO: Only works when we don't normalize under lambdas
- ValueKind::Var(_v, w) => TyExprKind::Var(venv.lookup(w)),
+ ValueKind::Var(v) => TyExprKind::Var(venv.lookup(v)),
ValueKind::LamClosure {
binder,
annot,
@@ -618,7 +616,7 @@ impl Closure {
match self {
Closure::Closure { arg_ty, .. } => {
let val = Value::from_kind_and_type(
- ValueKind::Var(AlphaVar::default(), var),
+ ValueKind::Var(var),
arg_ty.clone(),
);
self.apply(val)
diff --git a/dhall/src/semantics/core/var.rs b/dhall/src/semantics/core/var.rs
index 3458489..264b81d 100644
--- a/dhall/src/semantics/core/var.rs
+++ b/dhall/src/semantics/core/var.rs
@@ -1,16 +1,4 @@
-use crate::syntax::{Label, V};
-
-/// Stores an alpha-normalized variable.
-#[derive(Clone, Copy, Eq)]
-pub struct AlphaVar {
- alpha: V<()>,
-}
-// TODO: temporary hopefully
-impl std::cmp::PartialEq for AlphaVar {
- fn eq(&self, _other: &Self) -> bool {
- true
- }
-}
+use crate::syntax::Label;
// Exactly like a Label, but equality returns always true.
// This is so that ValueKind equality is exactly alpha-equivalence.
@@ -19,18 +7,6 @@ pub struct Binder {
name: Label,
}
-impl AlphaVar {
- pub(crate) fn new(alpha: V<()>) -> Self {
- AlphaVar { alpha }
- }
- pub(crate) fn default() -> Self {
- AlphaVar { alpha: V((), 0) }
- }
- pub(crate) fn idx(&self) -> usize {
- self.alpha.idx()
- }
-}
-
impl Binder {
pub(crate) fn new(name: Label) -> Self {
Binder { name }
@@ -47,12 +23,6 @@ impl std::cmp::PartialEq for Binder {
}
}
-impl std::fmt::Debug for AlphaVar {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "AlphaVar({})", self.alpha.1)
- }
-}
-
impl std::fmt::Debug for Binder {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Binder({})", &self.name)
diff --git a/dhall/src/semantics/core/visitor.rs b/dhall/src/semantics/core/visitor.rs
index aec66f8..2191ce3 100644
--- a/dhall/src/semantics/core/visitor.rs
+++ b/dhall/src/semantics/core/visitor.rs
@@ -96,7 +96,7 @@ where
v.visit_vec(types)?,
env.clone(),
),
- Var(v, w) => Var(v.clone(), *w),
+ Var(v) => Var(*v),
Const(k) => Const(*k),
BoolLit(b) => BoolLit(*b),
NaturalLit(n) => NaturalLit(*n),