summaryrefslogtreecommitdiff
path: root/dhall_core/src/core.rs
diff options
context:
space:
mode:
authorNadrieril2019-04-12 16:32:29 +0200
committerNadrieril2019-04-12 16:32:29 +0200
commit5fcc7f69c7a68b08ff223217e8af9f8edb2cc761 (patch)
treeda5c9d6e936ba97d7ccadc213ea2c5a197ebe15b /dhall_core/src/core.rs
parentedac7d46abda23c9149336586c80c62d85aced70 (diff)
Capture `Span`s in the AST and thread them through Parsed and Resolved
Diffstat (limited to 'dhall_core/src/core.rs')
-rw-r--r--dhall_core/src/core.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs
index 7d0f7cd..5b138b8 100644
--- a/dhall_core/src/core.rs
+++ b/dhall_core/src/core.rs
@@ -643,6 +643,39 @@ impl<N: Clone> SubExpr<N, X> {
}
}
+impl<E: Clone> SubExpr<X, E> {
+ pub fn note_absurd<N>(&self) -> SubExpr<N, E> {
+ rc(self.as_ref().map_ref(
+ |e| e.note_absurd(),
+ |_, e| e.note_absurd(),
+ |_| unreachable!(),
+ E::clone,
+ Label::clone,
+ ))
+ }
+}
+
+impl<E: Clone> Expr<X, E> {
+ pub fn note_absurd<N: Clone>(&self) -> Expr<N, E> {
+ self.roll().note_absurd().unroll()
+ }
+}
+
+impl<N: Clone, E: Clone> SubExpr<N, E> {
+ pub fn unnote(&self) -> SubExpr<X, E> {
+ match self.as_ref() {
+ ExprF::Note(_, e) => e.unnote(),
+ e => rc(e.map_ref(
+ |e| e.unnote(),
+ |_, e| e.unnote(),
+ |_| unreachable!(),
+ E::clone,
+ Label::clone,
+ )),
+ }
+ }
+}
+
impl<N: Clone> Expr<N, X> {
// This is all very sad and I hope this can be avoided sometime
pub fn absurd_rec<T>(&self) -> Expr<N, T> {