diff options
author | Nadrieril | 2019-04-07 18:04:45 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-07 18:04:45 +0200 |
commit | 21b1fda39e51d157dadbfbb2aeb0f542a9506fcf (patch) | |
tree | 09012b2d9294a58455b74e8bd0e041f7cb153a23 /dhall/src/expr.rs | |
parent | 727c5219c9af55df3e61fb372fa2fadecdd15b18 (diff) | |
parent | 4bebcd96b6e76b9b8ae7877af91d2ae571e617a9 (diff) |
Merge branch 'statemachine-api'
Diffstat (limited to 'dhall/src/expr.rs')
-rw-r--r-- | dhall/src/expr.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs new file mode 100644 index 0000000..7baf628 --- /dev/null +++ b/dhall/src/expr.rs @@ -0,0 +1,46 @@ +use crate::imports::ImportRoot; +use dhall_core::*; + +macro_rules! derive_other_traits { + ($ty:ident) => { + impl std::cmp::PartialEq for $ty { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } + } + + impl std::fmt::Display for $ty { + fn fmt( + &self, + f: &mut std::fmt::Formatter, + ) -> Result<(), std::fmt::Error> { + self.0.fmt(f) + } + } + }; +} + +#[derive(Debug, Clone, Eq)] +pub struct Parsed(pub(crate) SubExpr<X, Import>, pub(crate) ImportRoot); +derive_other_traits!(Parsed); + +#[derive(Debug, Clone, Eq)] +pub struct Resolved(pub(crate) SubExpr<X, X>); +derive_other_traits!(Resolved); + +#[derive(Debug, Clone, Eq)] +pub struct Typed(pub(crate) SubExpr<X, X>, pub(crate) Type); +derive_other_traits!(Typed); + +#[derive(Debug, Clone, Eq)] +pub struct Normalized(pub(crate) SubExpr<X, X>, pub(crate) Type); +derive_other_traits!(Normalized); + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Type(pub(crate) TypeInternal); + +#[derive(Debug, Clone, PartialEq, Eq)] +pub(crate) enum TypeInternal { + Expr(Box<Normalized>), + Untyped, +} |