summaryrefslogtreecommitdiff
path: root/dhall/src/semantics/core/var.rs
diff options
context:
space:
mode:
authorNadrieril2020-01-17 18:42:13 +0000
committerNadrieril2020-01-17 18:42:13 +0000
commit0f4a4801ed67826dc82015d39ce8fd05e7950035 (patch)
treef8393bb9e8abaccc8db0e1c17ae1d1a39b88ff7b /dhall/src/semantics/core/var.rs
parentab672506fd45e33f60b1b962c4757f912b6e27be (diff)
Replace all bulk shifting by a single shift
Diffstat (limited to '')
-rw-r--r--dhall/src/semantics/core/var.rs20
1 files changed, 4 insertions, 16 deletions
diff --git a/dhall/src/semantics/core/var.rs b/dhall/src/semantics/core/var.rs
index f3475e7..93776bf 100644
--- a/dhall/src/semantics/core/var.rs
+++ b/dhall/src/semantics/core/var.rs
@@ -1,5 +1,3 @@
-use std::collections::HashMap;
-
use crate::syntax::{Label, V};
/// Stores an alpha-normalized variable.
@@ -16,6 +14,9 @@ pub struct Binder {
}
impl AlphaVar {
+ pub(crate) fn default() -> Self {
+ AlphaVar { alpha: V((), 0) }
+ }
pub(crate) fn idx(&self) -> usize {
self.alpha.idx()
}
@@ -35,14 +36,6 @@ impl AlphaVar {
pub(crate) fn over_binder(&self, x: &AlphaVar) -> Option<Self> {
self.shift(-1, x)
}
- pub(crate) fn under_multiple_binders(
- &self,
- shift_map: &HashMap<Label, usize>,
- ) -> Self {
- AlphaVar {
- alpha: self.alpha.under_multiple_binders(shift_map),
- }
- }
}
impl Binder {
@@ -89,11 +82,6 @@ impl std::fmt::Debug for Binder {
}
}
-impl<'a> From<&'a Label> for AlphaVar {
- fn from(x: &'a Label) -> AlphaVar {
- AlphaVar { alpha: V((), 0) }
- }
-}
impl From<Binder> for AlphaVar {
fn from(x: Binder) -> AlphaVar {
AlphaVar { alpha: V((), 0) }
@@ -101,7 +89,7 @@ impl From<Binder> for AlphaVar {
}
impl<'a> From<&'a Binder> for AlphaVar {
fn from(x: &'a Binder) -> AlphaVar {
- x.clone().into()
+ AlphaVar { alpha: V((), 0) }
}
}