From ab100be616932dab22a5309df86107b66e93db37 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 4 May 2019 18:41:22 +0200 Subject: Revert "Make SubExpr generic in the variable labels type" This reverts commit 4c159640e5ee77ffa48b85a5bffa56350cf933ef. --- dhall_syntax/src/printer.rs | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'dhall_syntax/src/printer.rs') diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index 9cc1b46..e3b180b 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -3,9 +3,7 @@ use itertools::Itertools; use std::fmt::{self, Display}; /// Generic instance that delegates to subexpressions -impl Display - for ExprF -{ +impl Display for ExprF { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { use crate::ExprF::*; match self { @@ -15,10 +13,9 @@ impl Display BoolIf(a, b, c) => { write!(f, "if {} then {} else {}", a, b, c)?; } - // TODO: arrow type - // Pi(a, b, c) if &String::from(a) == "_" => { - // write!(f, "{} → {}", b, c)?; - // } + Pi(a, b, c) if &String::from(a) == "_" => { + write!(f, "{} → {}", b, c)?; + } Pi(a, b, c) => { write!(f, "∀({} : {}) → {}", a, b, c)?; } @@ -127,25 +124,21 @@ enum PrintPhase { // Wraps an Expr with a phase, so that phase selsction can be done // separate from the actual printing #[derive(Clone)] -struct PhasedExpr<'a, L, S, A>(&'a SubExpr, PrintPhase); +struct PhasedExpr<'a, S, A>(&'a SubExpr, PrintPhase); -impl<'a, L: Display + Clone, S: Clone, A: Display + Clone> Display - for PhasedExpr<'a, L, S, A> -{ +impl<'a, S: Clone, A: Display + Clone> Display for PhasedExpr<'a, S, A> { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { self.0.as_ref().fmt_phase(f, self.1) } } -impl<'a, L: Display + Clone, S: Clone, A: Display + Clone> - PhasedExpr<'a, L, S, A> -{ - fn phase(self, phase: PrintPhase) -> PhasedExpr<'a, L, S, A> { +impl<'a, S: Clone, A: Display + Clone> PhasedExpr<'a, S, A> { + fn phase(self, phase: PrintPhase) -> PhasedExpr<'a, S, A> { PhasedExpr(self.0, phase) } } -impl Expr { +impl Expr { fn fmt_phase( &self, f: &mut fmt::Formatter, @@ -179,12 +172,11 @@ impl Expr { // Annotate subexpressions with the appropriate phase, defaulting to Base let phased_self = match self.map_ref_simple(|e| PhasedExpr(e, Base)) { Pi(a, b, c) => { - // TODO: arrow type - // if &String::from(&a) == "_" { - // Pi(a, b.phase(Operator), c) - // } else { - Pi(a, b, c) - // } + if &String::from(&a) == "_" { + Pi(a, b.phase(Operator), c) + } else { + Pi(a, b, c) + } } Merge(a, b, c) => Merge( a.phase(Import), @@ -220,9 +212,7 @@ impl Expr { } } -impl Display - for SubExpr -{ +impl Display for SubExpr { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { self.as_ref().fmt_phase(f, PrintPhase::Base) } @@ -484,9 +474,9 @@ impl Display for Scheme { } } -impl Display for Var