diff options
author | Nadrieril | 2019-04-22 00:56:47 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-22 00:56:47 +0200 |
commit | a5c94605e29f3694928d6e03de325c0c81fee7b2 (patch) | |
tree | aae0a5edf7ad405ec23c94d0c0e6a2695a4b4d2e /dhall/src/expr.rs | |
parent | 0f334c9d112e3ee961eb35c09c85140fdf2aa8f6 (diff) |
Store context in Typed
Diffstat (limited to 'dhall/src/expr.rs')
-rw-r--r-- | dhall/src/expr.rs | 20 |
1 files changed, 14 insertions, 6 deletions
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<Span<'a>, Import>, pub(crate) ImportRoot, ); derive_other_traits!(Parsed); -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone)] pub(crate) struct Resolved<'a>( pub(crate) SubExpr<Span<'a>, Normalized<'static>>, ); derive_other_traits!(Resolved); -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone)] pub(crate) struct Typed<'a>( pub(crate) SubExpr<X, Normalized<'static>>, pub(crate) Option<Type<'static>>, + 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<X, X>, pub(crate) Option<Type<'static>>, @@ -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<X, X>, pub(crate) PhantomData<&'a ()>, @@ -101,7 +104,12 @@ impl<'a> From<SubExpr<X, X>> for SimpleType<'a> { #[doc(hidden)] impl<'a> From<Normalized<'a>> 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, + ) } } |