summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
authorNadrieril2019-08-31 21:59:39 +0200
committerNadrieril2019-08-31 21:59:39 +0200
commitaba7e62e49ac9dead0a2868f739091d2d15ff0d1 (patch)
tree6c257318d9706ed1ea1336eef2059ac826719194 /dhall/src
parenta2c2cd76d256a4e6ca66b9b1bd756fb17e600ef5 (diff)
Implement parsing of `toMap` keyword
Diffstat (limited to '')
-rw-r--r--dhall/src/phase/binary.rs11
-rw-r--r--dhall/src/phase/normalize.rs1
-rw-r--r--dhall/src/phase/typecheck.rs1
3 files changed, 13 insertions, 0 deletions
diff --git a/dhall/src/phase/binary.rs b/dhall/src/phase/binary.rs
index 7dc9be2..40219d9 100644
--- a/dhall/src/phase/binary.rs
+++ b/dhall/src/phase/binary.rs
@@ -366,6 +366,15 @@ fn cbor_value_to_dhall(data: &cbor::Value) -> Result<DecodedExpr, DecodeError> {
let y = cbor_value_to_dhall(&y)?;
Annot(x, y)
}
+ [U64(27), x] => {
+ let x = cbor_value_to_dhall(&x)?;
+ ToMap(x, None)
+ }
+ [U64(27), x, y] => {
+ let x = cbor_value_to_dhall(&x)?;
+ let y = cbor_value_to_dhall(&y)?;
+ ToMap(x, Some(y))
+ }
[U64(28), x] => {
let x = cbor_value_to_dhall(&x)?;
EmptyListLit(x)
@@ -550,6 +559,8 @@ where
Merge(x, y, Some(z)) => {
ser_seq!(ser; tag(6), expr(x), expr(y), expr(z))
}
+ ToMap(x, None) => ser_seq!(ser; tag(27), expr(x)),
+ ToMap(x, Some(y)) => ser_seq!(ser; tag(27), expr(x), expr(y)),
Projection(x, ls) => ser.collect_seq(
once(tag(10))
.chain(once(expr(x)))
diff --git a/dhall/src/phase/normalize.rs b/dhall/src/phase/normalize.rs
index 82a378c..3f6e99c 100644
--- a/dhall/src/phase/normalize.rs
+++ b/dhall/src/phase/normalize.rs
@@ -765,6 +765,7 @@ pub(crate) fn normalize_one_layer(
}
}
}
+ ExprF::ToMap(_, _) => unimplemented!("toMap"),
};
match ret {
diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs
index 52a4e47..9013c1f 100644
--- a/dhall/src/phase/typecheck.rs
+++ b/dhall/src/phase/typecheck.rs
@@ -757,6 +757,7 @@ fn type_last_layer(
(None, None) => return mkerr(MergeEmptyNeedsAnnotation),
}
}
+ ToMap(_, _) => unimplemented!("toMap"),
Projection(record, labels) => {
let record_type = record.get_type()?;
let record_borrow = record_type.as_whnf();