From 711164a7a24ab832006b72cac162e78cf434861a Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 4 Aug 2019 11:11:37 +0200 Subject: Remove old-style optional literals --- dhall_syntax/src/core/expr.rs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'dhall_syntax/src/core/expr.rs') diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index da9465d..df2dc97 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -194,10 +194,6 @@ pub enum ExprF { EmptyListLit(SubExpr), /// `[x, y, z]` NEListLit(Vec), - /// Deprecated Optional literal form - /// `[] : Optional a` - /// `[x] : Optional a` - OldOptionalLit(Option, SubExpr), /// `Some e` SomeLit(SubExpr), /// `{ k1 : t1, k2 : t1 }` -- cgit v1.2.3 From 696efe66336a268054c475fab9fe6505bdfc7b60 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 4 Aug 2019 13:00:56 +0200 Subject: Add some new tests and implement import alternatives --- dhall_syntax/src/core/expr.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'dhall_syntax/src/core/expr.rs') diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index df2dc97..e33859b 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -307,6 +307,35 @@ impl Expr { { trivial_result(self.traverse_embed(|x| Ok(map_embed(x)))) } + + pub fn traverse_resolve( + &self, + visit_embed: impl FnMut(&E) -> Result, + ) -> Result, Err> + where + N: Clone, + { + self.traverse_resolve_with_visitor(&mut visitor::ResolveVisitor( + visit_embed, + )) + } + + pub(crate) fn traverse_resolve_with_visitor( + &self, + visitor: &mut visitor::ResolveVisitor, + ) -> Result, Err> + where + N: Clone, + F1: FnMut(&E) -> Result, + { + match self { + ExprF::BinOp(BinOp::ImportAlt, l, r) => l + .as_ref() + .traverse_resolve_with_visitor(visitor) + .or(r.as_ref().traverse_resolve_with_visitor(visitor)), + _ => self.visit(visitor), + } + } } impl Expr { @@ -383,6 +412,16 @@ impl SubExpr { )), } } + + pub fn traverse_resolve( + &self, + visit_embed: impl FnMut(&E) -> Result, + ) -> Result, Err> + where + N: Clone, + { + Ok(self.rewrap(self.as_ref().traverse_resolve(visit_embed)?)) + } } impl SubExpr { -- cgit v1.2.3 From f7b0c6b9c52f65624dc765fb9eaa7d0d94eeae76 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 6 Aug 2019 23:03:01 +0200 Subject: Generalize empty list annotations --- dhall_syntax/src/core/expr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dhall_syntax/src/core/expr.rs') diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index e33859b..14dc165 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -190,7 +190,7 @@ pub enum ExprF { DoubleLit(Double), /// `"Some ${interpolated} text"` TextLit(InterpolatedText), - /// `[] : List t` + /// `[] : t` EmptyListLit(SubExpr), /// `[x, y, z]` NEListLit(Vec), -- cgit v1.2.3 From 2755cb01092363062016bc51349870b1330d1d6f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 7 Aug 2019 15:58:57 +0200 Subject: Sort labels in projection expressions --- dhall_syntax/src/core/expr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dhall_syntax/src/core/expr.rs') diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index 14dc165..668ab45 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -1,6 +1,6 @@ use std::rc::Rc; -use crate::map::DupTreeMap; +use crate::map::{DupTreeMap, DupTreeSet}; use crate::visitor; use crate::*; @@ -209,7 +209,7 @@ pub enum ExprF { /// `e.x` Field(SubExpr, Label), /// `e.{ x, y, z }` - Projection(SubExpr, Vec