From 7374d0524ccd53b256107667b213597c05720d2d Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 31 Mar 2019 19:08:08 +0200 Subject: Move recursion out of Expr --- dhall/src/binary.rs | 4 ++-- dhall/src/normalize.rs | 6 +++--- dhall/src/typecheck.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'dhall/src') diff --git a/dhall/src/binary.rs b/dhall/src/binary.rs index 988891b..1ba1873 100644 --- a/dhall/src/binary.rs +++ b/dhall/src/binary.rs @@ -20,10 +20,10 @@ pub fn decode(data: &[u8]) -> Result { fn cbor_value_to_dhall(data: &cbor::Value) -> Result { use cbor::Value::*; use dhall_core::{BinOp, Builtin, Const}; - use Expr::*; + use ExprF::*; Ok(rc(match data { String(s) => match Builtin::parse(s) { - Some(b) => Expr::Builtin(b), + Some(b) => ExprF::Builtin(b), None => match s.as_str() { "True" => BoolLit(true), "False" => BoolLit(false), diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index 5405e88..c6c294c 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -12,7 +12,7 @@ where A: fmt::Debug, { use dhall_core::Builtin::*; - use dhall_core::Expr::*; + use dhall_core::ExprF::*; let f = rc(Builtin(b)); // How many arguments a builtin needs, and which argument // should be normalized and pattern-matched @@ -199,7 +199,7 @@ where // Put the remaining arguments back and eval again. In most cases // ret will not be of a form that can be applied, so this won't go very deep. // In lots of cases, there are no remaining args so this cann will just return ret. - normalize_whnf(&rc(Expr::App(ret, args.split_off(len_consumption)))) + normalize_whnf(&rc(ExprF::App(ret, args.split_off(len_consumption)))) } /// Reduce an expression to its weak head normal form, i.e. normalize @@ -213,7 +213,7 @@ where A: fmt::Debug, { use dhall_core::BinOp::*; - use dhall_core::Expr::*; + use dhall_core::ExprF::*; match e.as_ref() { Let(f, _, r, b) => { let vf0 = &V(f.clone(), 0); diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs index e769c7f..31702db 100644 --- a/dhall/src/typecheck.rs +++ b/dhall/src/typecheck.rs @@ -12,7 +12,7 @@ use self::TypeMessage::*; fn axiom(c: Const) -> Result> { use dhall_core::Const::*; - use dhall_core::Expr::*; + use dhall_core::ExprF::*; match c { Type => Ok(Kind), Kind => Err(TypeError::new(&Context::new(), rc(Const(Kind)), Untyped)), @@ -53,7 +53,7 @@ where S: ::std::fmt::Debug, T: ::std::fmt::Debug, { - use dhall_core::Expr::*; + use dhall_core::ExprF::*; fn go( ctx: &mut Vec<(Label, Label)>, el: &Expr, @@ -192,7 +192,7 @@ where use dhall_core::BinOp::*; use dhall_core::Builtin::*; use dhall_core::Const::*; - use dhall_core::Expr::*; + use dhall_core::ExprF::*; let mkerr = |msg: TypeMessage<_>| TypeError::new(ctx, e.clone(), msg); let ensure_const = |x: &SubExpr<_, _>, msg: TypeMessage<_>| match x.as_ref() { -- cgit v1.2.3