diff options
author | FintanH | 2019-08-12 22:34:21 +0100 |
---|---|---|
committer | FintanH | 2019-08-12 22:34:21 +0100 |
commit | 4a86274878d5ab0ef4f9d8597606226adfd048de (patch) | |
tree | 68153eb0e4283740f49042e059402da6eaaf551e /dhall_syntax/src/core/visitor.rs | |
parent | 405bc3d80c0e169ea74dd12422b9504b7383dab3 (diff) | |
parent | 7d17d39005531cb77d8eaf32ed7de8938c66f874 (diff) |
Merge remote-tracking branch 'origin/master' into fintan/canonicalize
Diffstat (limited to 'dhall_syntax/src/core/visitor.rs')
-rw-r--r-- | dhall_syntax/src/core/visitor.rs | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/dhall_syntax/src/core/visitor.rs b/dhall_syntax/src/core/visitor.rs index 99a9c11..18f76d9 100644 --- a/dhall_syntax/src/core/visitor.rs +++ b/dhall_syntax/src/core/visitor.rs @@ -137,17 +137,10 @@ where ), EmptyListLit(t) => EmptyListLit(v.visit_subexpr(t)?), NEListLit(es) => NEListLit(vec(es, |e| v.visit_subexpr(e))?), - OldOptionalLit(x, t) => OldOptionalLit( - opt(x, |e| v.visit_subexpr(e))?, - v.visit_subexpr(t)?, - ), SomeLit(e) => SomeLit(v.visit_subexpr(e)?), RecordType(kts) => RecordType(dupmap(kts, v)?), RecordLit(kvs) => RecordLit(dupmap(kvs, v)?), UnionType(kts) => UnionType(optdupmap(kts, v)?), - UnionLit(k, x, kts) => { - UnionLit(k.clone(), v.visit_subexpr(x)?, optdupmap(kts, v)?) - } Merge(x, y, t) => Merge( v.visit_subexpr(x)?, v.visit_subexpr(y)?, @@ -155,6 +148,7 @@ where ), Field(e, l) => Field(v.visit_subexpr(e)?, l.clone()), Projection(e, ls) => Projection(v.visit_subexpr(e)?, ls.clone()), + Assert(e) => Assert(v.visit_subexpr(e)?), Embed(a) => return v.visit_embed_squash(a), }) } @@ -362,6 +356,31 @@ where } } +pub struct ResolveVisitor<F1>(pub F1); + +impl<'a, 'b, N, E, E2, Err, F1> + ExprFFallibleVisitor<'a, SubExpr<N, E>, SubExpr<N, E2>, E, E2> + for &'b mut ResolveVisitor<F1> +where + N: Clone + 'a, + F1: FnMut(&E) -> Result<E2, Err>, +{ + type Error = Err; + + fn visit_subexpr( + &mut self, + subexpr: &'a SubExpr<N, E>, + ) -> Result<SubExpr<N, E2>, Self::Error> { + Ok(subexpr.rewrap( + subexpr + .as_ref() + .traverse_resolve_with_visitor(&mut **self)?, + )) + } + fn visit_embed(self, embed: &'a E) -> Result<E2, Self::Error> { + (self.0)(embed) + } +} pub struct NoteAbsurdVisitor; impl<'a, 'b, N, E> |