summaryrefslogtreecommitdiff
path: root/dhall/src/core/var.rs
diff options
context:
space:
mode:
authorNadrieril2019-08-15 13:08:25 +0200
committerNadrieril2019-08-15 13:08:25 +0200
commita9804009f405be7e8a89e301f280ee9d51b57e5e (patch)
tree259f349488ef08280e62ceb6d5203ba9fb8d0881 /dhall/src/core/var.rs
parentaabca76a62256aa7cad66c2016ed504e49651d5a (diff)
Custom Debug impls to improve debug legibility
Diffstat (limited to '')
-rw-r--r--dhall/src/core/var.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/dhall/src/core/var.rs b/dhall/src/core/var.rs
index 0faa091..d53c194 100644
--- a/dhall/src/core/var.rs
+++ b/dhall/src/core/var.rs
@@ -5,7 +5,7 @@ use dhall_syntax::{Label, V};
/// Stores a pair of variables: a normal one and if relevant one
/// that corresponds to the alpha-normalized version of the first one.
/// Equality is up to alpha-equivalence.
-#[derive(Debug, Clone, Eq)]
+#[derive(Clone, Eq)]
pub struct AlphaVar {
normal: V<Label>,
alpha: Option<V<()>>,
@@ -13,7 +13,7 @@ pub struct AlphaVar {
// Exactly like a Label, but equality returns always true.
// This is so that Value equality is exactly alpha-equivalence.
-#[derive(Debug, Clone, Eq)]
+#[derive(Clone, Eq)]
pub struct AlphaLabel(Label);
pub trait Shift: Sized {
@@ -125,6 +125,21 @@ impl std::cmp::PartialEq for AlphaLabel {
}
}
+impl std::fmt::Debug for AlphaVar {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match &self.alpha {
+ Some(a) => write!(f, "AlphaVar({}, {})", self.normal, a.1),
+ None => write!(f, "AlphaVar({}, free)", self.normal),
+ }
+ }
+}
+
+impl std::fmt::Debug for AlphaLabel {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "AlphaLabel({})", &self.0)
+ }
+}
+
impl From<Label> for AlphaVar {
fn from(x: Label) -> AlphaVar {
AlphaVar {