diff options
author | Nadrieril | 2019-04-06 11:09:23 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-06 11:09:23 +0200 |
commit | 0cf4d3845e75ac25e35c5e73eb2dfd58c5450af6 (patch) | |
tree | 4cf5119a66fc7baeb66cb44a171d5a290429da18 /dhall_core | |
parent | 5b0e81c215fa6323635ca1bf49a86aeef0ba80f8 (diff) |
Factor out shift/subst/shift dance
Diffstat (limited to 'dhall_core')
-rw-r--r-- | dhall_core/src/core.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 3d1b9f3..2f15217 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -739,3 +739,13 @@ pub fn subst<S, A>( _ => in_expr.map_ref(|e| subst(var, value, e), under_binder), } } + +pub fn subst_shift<S, A>( + var: &V<Label>, + value: &SubExpr<S, A>, + in_expr: &SubExpr<S, A>, +) -> SubExpr<S, A> { + let value = shift(1, var, value); + let expr = subst(var, &value, in_expr); + shift(-1, var, &expr) +} |