From b3f00a827bcdd0fe406ccf8913cc5fb7cd6e0f2f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 7 May 2019 18:38:54 +0200 Subject: Promote shift and subst_shift to traits --- dhall/src/core/value.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'dhall/src/core/value.rs') diff --git a/dhall/src/core/value.rs b/dhall/src/core/value.rs index 4c71778..412fe11 100644 --- a/dhall/src/core/value.rs +++ b/dhall/src/core/value.rs @@ -7,7 +7,7 @@ use dhall_syntax::{ }; use crate::core::thunk::{Thunk, TypeThunk}; -use crate::core::var::{AlphaLabel, AlphaVar}; +use crate::core::var::{AlphaLabel, AlphaVar, Shift, Subst}; use crate::phase::normalize::{ apply_builtin, normalize_one_layer, squash_textlit, OutputSubExpr, }; @@ -316,8 +316,10 @@ impl Value { pub(crate) fn from_builtin(b: Builtin) -> Value { Value::AppliedBuiltin(b, vec![]) } +} - pub(crate) fn shift(&self, delta: isize, var: &AlphaVar) -> Self { +impl Shift for Value { + fn shift(&self, delta: isize, var: &AlphaVar) -> Self { match self { Value::Lam(x, t, e) => Value::Lam( x.clone(), @@ -413,8 +415,10 @@ impl Value { } } } +} - pub(crate) fn subst_shift(&self, var: &AlphaVar, val: &Typed) -> Self { +impl Subst for Value { + fn subst_shift(&self, var: &AlphaVar, val: &Typed) -> Self { match self { // Retry normalizing since substituting may allow progress Value::AppliedBuiltin(b, args) => apply_builtin( -- cgit v1.2.3