From a5c94605e29f3694928d6e03de325c0c81fee7b2 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 22 Apr 2019 00:56:47 +0200 Subject: Store context in Typed --- dhall/src/expr.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'dhall/src/expr.rs') diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs index 44d1612..1840eba 100644 --- a/dhall/src/expr.rs +++ b/dhall/src/expr.rs @@ -10,6 +10,8 @@ macro_rules! derive_other_traits { } } + impl<'a> std::cmp::Eq for $ty<'a> {} + impl<'a> std::fmt::Display for $ty<'a> { fn fmt( &self, @@ -21,28 +23,29 @@ macro_rules! derive_other_traits { }; } -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone)] pub(crate) struct Parsed<'a>( pub(crate) SubExpr, Import>, pub(crate) ImportRoot, ); derive_other_traits!(Parsed); -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone)] pub(crate) struct Resolved<'a>( pub(crate) SubExpr, Normalized<'static>>, ); derive_other_traits!(Resolved); -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone)] pub(crate) struct Typed<'a>( pub(crate) SubExpr>, pub(crate) Option>, + pub(crate) crate::typecheck::TypecheckContext, pub(crate) PhantomData<&'a ()>, ); derive_other_traits!(Typed); -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone)] pub(crate) struct Normalized<'a>( pub(crate) SubExpr, pub(crate) Option>, @@ -56,7 +59,7 @@ derive_other_traits!(Normalized); /// `Bool`, `{ x: Integer }` or `Natural -> Text`. /// /// For a more general notion of "type", see [Type]. -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone)] pub struct SimpleType<'a>( pub(crate) SubExpr, pub(crate) PhantomData<&'a ()>, @@ -101,7 +104,12 @@ impl<'a> From> for SimpleType<'a> { #[doc(hidden)] impl<'a> From> for Typed<'a> { fn from(x: Normalized<'a>) -> Typed<'a> { - Typed(x.0.embed_absurd(), x.1, x.2) + Typed( + x.0.embed_absurd(), + x.1, + crate::typecheck::TypecheckContext::new(), + x.2, + ) } } -- cgit v1.2.3