From 474744de28034e9558b1a3ff4f9e21ec1425d794 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 6 Mar 2019 23:48:55 +0100 Subject: rustfmt --- dhall/src/normalize.rs | 72 ++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 31 deletions(-) (limited to 'dhall/src/normalize.rs') diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index b46722a..9dd384a 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -145,37 +145,47 @@ where }, // Normalize everything else before matching - e => match e.map_shallow(normalize, |_| unreachable!(), |x| x.clone()) { - BinOp(BoolAnd, box BoolLit(x), box BoolLit(y)) => BoolLit(x && y), - BinOp(BoolOr, box BoolLit(x), box BoolLit(y)) => BoolLit(x || y), - BinOp(BoolEQ, box BoolLit(x), box BoolLit(y)) => BoolLit(x == y), - BinOp(BoolNE, box BoolLit(x), box BoolLit(y)) => BoolLit(x != y), - BinOp(NaturalPlus, box NaturalLit(x), box NaturalLit(y)) => { - NaturalLit(x + y) - } - BinOp(NaturalTimes, box NaturalLit(x), box NaturalLit(y)) => { - NaturalLit(x * y) - } - BinOp(TextAppend, box TextLit(x), box TextLit(y)) => { - TextLit(x + &y) - } - BinOp(ListAppend, box ListLit(t1, xs), box ListLit(t2, ys)) => { - // Drop type annotation if the result is nonempty - let t = if xs.len() == 0 && ys.len() == 0 { - t1.or(t2) - } else { - None - }; - let xs = xs.into_iter(); - let ys = ys.into_iter(); - ListLit(t, xs.chain(ys).collect()) + e => { + match e.map_shallow(normalize, |_| unreachable!(), |x| x.clone()) { + BinOp(BoolAnd, box BoolLit(x), box BoolLit(y)) => { + BoolLit(x && y) + } + BinOp(BoolOr, box BoolLit(x), box BoolLit(y)) => { + BoolLit(x || y) + } + BinOp(BoolEQ, box BoolLit(x), box BoolLit(y)) => { + BoolLit(x == y) + } + BinOp(BoolNE, box BoolLit(x), box BoolLit(y)) => { + BoolLit(x != y) + } + BinOp(NaturalPlus, box NaturalLit(x), box NaturalLit(y)) => { + NaturalLit(x + y) + } + BinOp(NaturalTimes, box NaturalLit(x), box NaturalLit(y)) => { + NaturalLit(x * y) + } + BinOp(TextAppend, box TextLit(x), box TextLit(y)) => { + TextLit(x + &y) + } + BinOp(ListAppend, box ListLit(t1, xs), box ListLit(t2, ys)) => { + // Drop type annotation if the result is nonempty + let t = if xs.len() == 0 && ys.len() == 0 { + t1.or(t2) + } else { + None + }; + let xs = xs.into_iter(); + let ys = ys.into_iter(); + ListLit(t, xs.chain(ys).collect()) + } + Merge(_x, _y, _t) => unimplemented!(), + Field(box RecordLit(kvs), x) => match kvs.get(x) { + Some(r) => r.clone(), + None => Field(bx(RecordLit(kvs)), x), + }, + e => e, } - Merge(_x, _y, _t) => unimplemented!(), - Field(box RecordLit(kvs), x) => match kvs.get(x) { - Some(r) => r.clone(), - None => Field(bx(RecordLit(kvs)), x), - }, - e => e, - }, + } } } -- cgit v1.2.3