From 16ce1082465a11bf76df5f59530cde02bddc4f21 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 8 Mar 2019 00:07:09 +0100 Subject: Make Expr generic in its type of labels --- dhall/src/normalize.rs | 2 +- dhall/src/typecheck.rs | 7 +-- dhall_core/src/core.rs | 107 +++++++++++++++++++++++---------------------- dhall_core/src/parser.rs | 78 ++++++++++++++++----------------- dhall_generator/src/lib.rs | 4 +- 5 files changed, 100 insertions(+), 98 deletions(-) diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index 9dd384a..246a3c0 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -20,7 +20,7 @@ where { use dhall_core::BinOp::*; use dhall_core::Builtin::*; - use dhall_core::Expr::*; + use dhall_core::Expr_::*; match e { // Matches that don't normalize everything right away Let(f, _, r, b) => { diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs index befd8c4..e36a6fa 100644 --- a/dhall/src/typecheck.rs +++ b/dhall/src/typecheck.rs @@ -8,7 +8,7 @@ use dhall_core::context::Context; use dhall_core::core; use dhall_core::core::Builtin::*; use dhall_core::core::Const::*; -use dhall_core::core::Expr::*; +use dhall_core::core::Expr_::*; use dhall_core::core::{app, pi}; use dhall_core::core::{bx, shift, subst, Expr, V, X}; @@ -31,7 +31,7 @@ fn rule(a: core::Const, b: core::Const) -> Result { } } -fn match_vars(vl: &V, vr: &V, ctx: &[(&str, &str)]) -> bool { +fn match_vars(vl: &V<&str>, vr: &V<&str>, ctx: &[(&str, &str)]) -> bool { let xxs = ctx.get(0).map(|x| (x, ctx.split_at(1).1)); match (vl, vr, xxs) { (&V(xL, nL), &V(xR, nR), None) => xL == xR && nL == nR, @@ -186,6 +186,7 @@ where S: Clone + ::std::fmt::Debug + 'i, { use dhall_core::BinOp::*; + use dhall_core::Expr_; match *e { Const(c) => axiom(c).map(Const), //.map(Cow::Owned), Var(V(x, n)) => { @@ -489,7 +490,7 @@ where Builtin(ListIndexed) => { let mut m = BTreeMap::new(); m.insert("index", Builtin(Natural)); - m.insert("value", Expr::from("a")); + m.insert("value", Expr_::from("a")); Ok(pi( "a", Const(Type), diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index f2177b1..cbf0654 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -104,7 +104,7 @@ pub struct Import { /// appear as a numeric suffix. /// #[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub struct V<'i>(pub &'i str, pub usize); +pub struct V