diff options
author | Nadrieril | 2019-05-07 18:12:04 +0200 |
---|---|---|
committer | Nadrieril | 2019-05-07 18:12:04 +0200 |
commit | 3da450aa3fae23214aa982643b9bc4dd0ea4eaa6 (patch) | |
tree | 02e00cd008d2e7dc899b9211379596fe792f41c8 /dhall_syntax/src/core/expr.rs | |
parent | d8a3e831fb67f86269c4baa99f9f0798a73a7247 (diff) | |
parent | 14dfeb8e7d2aa87a361a711a485243449426b144 (diff) |
Merge branch 'reorganize'
Diffstat (limited to '')
-rw-r--r-- | dhall_syntax/src/core/expr.rs (renamed from dhall_syntax/src/core.rs) | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/dhall_syntax/src/core.rs b/dhall_syntax/src/core/expr.rs index 7cdda64..2b76b9a 100644 --- a/dhall_syntax/src/core.rs +++ b/dhall_syntax/src/core/expr.rs @@ -343,15 +343,11 @@ impl<N, E> Expr<N, E> { { trivial_result(self.traverse_embed(|x| Ok(map_embed(x)))) } +} - pub fn squash_embed<E2>( - &self, - f: impl FnMut(&E) -> SubExpr<N, E2>, - ) -> SubExpr<N, E2> - where - N: Clone, - { - trivial_result(self.visit(&mut visitor::SquashEmbedVisitor(f))) +impl Expr<X, X> { + pub fn absurd<N, E>(&self) -> Expr<N, E> { + self.visit(&mut visitor::AbsurdVisitor) } } @@ -361,12 +357,6 @@ impl<E: Clone> Expr<X, E> { } } -impl<N: Clone> Expr<N, X> { - pub fn embed_absurd<E>(&self) -> Expr<N, E> { - self.visit(&mut visitor::EmbedAbsurdVisitor) - } -} - impl<N, E> SubExpr<N, E> { pub fn as_ref(&self) -> &Expr<N, E> { &self.0.as_ref().0 @@ -380,17 +370,6 @@ impl<N, E> SubExpr<N, E> { SubExpr(Rc::new((x, None))) } - pub fn unnote(&self) -> SubExpr<X, E> - where - E: Clone, - { - SubExpr::from_expr_no_note( - self.as_ref().visit(&mut visitor::UnNoteVisitor), - ) - } -} - -impl<N: Clone, E> SubExpr<N, E> { pub fn rewrap<E2>(&self, x: Expr<N, E2>) -> SubExpr<N, E2> where N: Clone, @@ -422,7 +401,10 @@ impl<N: Clone, E> SubExpr<N, E> { &'a self, map_expr: impl FnMut(&'a Self) -> Self, map_under_binder: impl FnMut(&'a Label, &'a Self) -> Self, - ) -> Self { + ) -> Self + where + N: Clone, + { match self.as_ref() { ExprF::Embed(_) => SubExpr::clone(self), // This calls ExprF::map_ref @@ -436,9 +418,9 @@ impl<N: Clone, E> SubExpr<N, E> { } } -impl<N: Clone> SubExpr<N, X> { - pub fn embed_absurd<T>(&self) -> SubExpr<N, T> { - self.rewrap(self.as_ref().embed_absurd()) +impl SubExpr<X, X> { + pub fn absurd<N: Clone, T>(&self) -> SubExpr<N, T> { + SubExpr::from_expr_no_note(self.as_ref().absurd()) } } |