From cb24b56d83479c0fd95bf4dd09879118f4e3afd6 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 18 Apr 2019 12:10:47 +0200 Subject: Deprecate some things --- dhall_core/src/core.rs | 25 +++++-------------------- dhall_core/src/parser.rs | 2 +- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 1c1aa23..d0e908b 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -472,6 +472,7 @@ impl SubExpr { match self.as_ref() { ExprF::Embed(_) => SubExpr::clone(self), // Recursive call + // TODO: don't discard the note ! ExprF::Note(_, e) => e .map_subexprs_with_special_handling_of_binders( map_expr, @@ -505,8 +506,9 @@ impl SubExpr { } impl SubExpr { + // Deprecated, use embed_absurd instead pub fn absurd(&self) -> SubExpr { - rc(self.as_ref().absurd_rec()) + self.embed_absurd() } pub fn embed_absurd(&self) -> SubExpr { rc(self.as_ref().embed_absurd()) @@ -530,25 +532,8 @@ pub fn rc(x: Expr) -> SubExpr { SubExpr(Rc::new(x)) } -pub fn app(f: Expr, args: Vec>) -> Expr { - if args.is_empty() { - f - } else { - ExprF::App(rc(f), args) - } -} - -pub fn app_rc( - f: SubExpr, - args: Vec>, -) -> SubExpr { - if args.is_empty() { - f - } else { - rc(ExprF::App(f, args)) - } -} - +/// Add an isize to an usize +/// Panics on over/underflow fn add_ui(u: usize, i: isize) -> usize { if i < 0 { u.checked_sub(i.checked_neg().unwrap() as usize).unwrap() diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs index 1e47c16..2a30b2b 100644 --- a/dhall_core/src/parser.rs +++ b/dhall_core/src/parser.rs @@ -746,7 +746,7 @@ make_parser! { rule!(application_expression> as expression; span; children!( [expression(e)] => e, [expression(first), expression(rest)..] => { - spanned(span, app(first, rest.map(rc).collect())) + spanned(span, App(rc(first), rest.map(rc).collect())) }, )); -- cgit v1.2.3