From 8e4182f26b20b28f60fb0c21b3e08e19314de9a0 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 5 May 2019 00:43:41 +0200 Subject: Make Value equality be alpha-equivalence Closes #66, #65 --- dhall/src/expr.rs | 10 ++++- dhall/src/normalize.rs | 99 +++++++++++++++++++++++++++++++++++++++++++------- dhall/src/typecheck.rs | 11 ++---- 3 files changed, 99 insertions(+), 21 deletions(-) (limited to 'dhall') diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs index 90efd39..071bb92 100644 --- a/dhall/src/expr.rs +++ b/dhall/src/expr.rs @@ -44,7 +44,7 @@ pub(crate) struct Normalized(pub(crate) TypedInternal); impl std::cmp::PartialEq for Normalized { fn eq(&self, other: &Self) -> bool { - self.to_expr() == other.to_expr() + self.0 == other.0 } } @@ -153,6 +153,14 @@ mod typed { } } } + + impl std::cmp::PartialEq for TypedInternal { + fn eq(&self, other: &Self) -> bool { + self.to_value() == other.to_value() + } + } + + impl std::cmp::Eq for TypedInternal {} } /// A Dhall expression representing a simple type. diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index 3e13350..c11dd82 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -53,7 +53,7 @@ impl Typed { /// Stores a pair of variables: a normal one and if relevant one /// that corresponds to the alpha-normalized version of the first one. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Eq)] pub(crate) struct DoubleVar { normal: V