summaryrefslogtreecommitdiff
path: root/dhall/src/syntax
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall/src/syntax/ast/expr.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/dhall/src/syntax/ast/expr.rs b/dhall/src/syntax/ast/expr.rs
index eba2735..bc3ffa4 100644
--- a/dhall/src/syntax/ast/expr.rs
+++ b/dhall/src/syntax/ast/expr.rs
@@ -182,6 +182,19 @@ impl Expr {
let data = binary::encode(self)?;
Ok(crate::utils::sha256_hash(&data))
}
+
+ /// this wraps the expression into an additional let-binding
+ pub fn substitute_name(self, label: Label, value: Expr) -> Expr {
+ Expr::new(
+ ExprKind::Let(
+ label,
+ None,
+ value,
+ self
+ ),
+ Span::Artificial
+ )
+ }
}
// Empty enum to indicate that no error can occur