summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
authorNadrieril2019-03-06 23:48:55 +0100
committerNadrieril2019-03-06 23:48:55 +0100
commit474744de28034e9558b1a3ff4f9e21ec1425d794 (patch)
tree8316d086b816e62bd185826fc8f58b46ffe17e92 /dhall/src
parente3813e7d4e3450704c1213fd6cdff7c801ccbc34 (diff)
rustfmt
Diffstat (limited to 'dhall/src')
-rw-r--r--dhall/src/imports.rs7
-rw-r--r--dhall/src/lib.rs2
-rw-r--r--dhall/src/normalize.rs72
3 files changed, 46 insertions, 35 deletions
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs
index 32ddfd7..6d8d670 100644
--- a/dhall/src/imports.rs
+++ b/dhall/src/imports.rs
@@ -1,11 +1,12 @@
-use dhall_core::{Expr, Import, ImportLocation, ImportMode, FilePrefix, X};
-
+use dhall_core::{Expr, FilePrefix, Import, ImportLocation, ImportMode, X};
// fn resolve_import(import: Import) -> Expr<X, Import> {
// }
-pub fn resolve_imports<'i, S: Clone>(expr: &Expr<'i, S, Import>) -> Expr<'i, S, X> {
+pub fn resolve_imports<'i, S: Clone>(
+ expr: &Expr<'i, S, Import>,
+) -> Expr<'i, S, X> {
let no_import = |_: &Import| -> X { panic!("ahhh import") };
expr.map_embed(&no_import)
}
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index 54f0983..4e56264 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -4,5 +4,5 @@
mod normalize;
pub use crate::normalize::*;
-pub mod typecheck;
pub mod imports;
+pub mod typecheck;
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,
- },
+ }
}
}