summaryrefslogtreecommitdiff
path: root/dhall/src/normalize.rs
diff options
context:
space:
mode:
authorNadrieril2019-03-06 23:48:55 +0100
committerNadrieril2019-03-06 23:48:55 +0100
commit474744de28034e9558b1a3ff4f9e21ec1425d794 (patch)
tree8316d086b816e62bd185826fc8f58b46ffe17e92 /dhall/src/normalize.rs
parente3813e7d4e3450704c1213fd6cdff7c801ccbc34 (diff)
rustfmt
Diffstat (limited to '')
-rw-r--r--dhall/src/normalize.rs72
1 files changed, 41 insertions, 31 deletions
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,
- },
+ }
}
}