summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2019-08-07 21:05:01 +0200
committerNadrieril2019-08-07 21:05:01 +0200
commitd248762095908246951b6aa6c211587c6e333c0e (patch)
tree688d4c1c199fd8f759d41c65e4dbc8bde9cc6614 /dhall
parent0c9831e6a851e8f91bddc33e7a163f49d60aa033 (diff)
Remove union literals from the language
Diffstat (limited to 'dhall')
-rw-r--r--dhall/src/core/value.rs15
-rw-r--r--dhall/src/phase/binary.rs12
-rw-r--r--dhall/src/phase/normalize.rs7
-rw-r--r--dhall/src/phase/typecheck.rs9
4 files changed, 6 insertions, 37 deletions
diff --git a/dhall/src/core/value.rs b/dhall/src/core/value.rs
index f47f1b2..d7b9149 100644
--- a/dhall/src/core/value.rs
+++ b/dhall/src/core/value.rs
@@ -178,19 +178,10 @@ impl Value {
.collect();
rc(ExprF::Field(rc(ExprF::UnionType(kts)), l.clone()))
}
- Value::UnionLit(l, v, kts) => rc(ExprF::UnionLit(
- l.clone(),
+ Value::UnionLit(l, v, kts) => rc(ExprF::App(
+ Value::UnionConstructor(l.clone(), kts.clone())
+ .normalize_to_expr_maybe_alpha(alpha),
v.normalize_to_expr_maybe_alpha(alpha),
- kts.iter()
- .map(|(k, v)| {
- (
- k.clone(),
- v.as_ref().map(|v| {
- v.normalize_to_expr_maybe_alpha(alpha)
- }),
- )
- })
- .collect(),
)),
Value::TextLit(elts) => {
use InterpolatedTextContents::{Expr, Text};
diff --git a/dhall/src/phase/binary.rs b/dhall/src/phase/binary.rs
index e44b1e2..bfe217f 100644
--- a/dhall/src/phase/binary.rs
+++ b/dhall/src/phase/binary.rs
@@ -160,12 +160,9 @@ fn cbor_value_to_dhall(
let map = cbor_map_to_dhall_opt_map(map)?;
UnionType(map)
}
- [U64(12), String(l), x, Object(map)] => {
- let map = cbor_map_to_dhall_opt_map(map)?;
- let x = cbor_value_to_dhall(&x)?;
- let l = Label::from(l.as_str());
- UnionLit(l, x, map)
- }
+ [U64(12), ..] => Err(DecodeError::WrongFormatError(
+ "Union literals are not supported anymore".to_owned(),
+ ))?,
[U64(14), x, y, z] => {
let x = cbor_value_to_dhall(&x)?;
let y = cbor_value_to_dhall(&y)?;
@@ -496,9 +493,6 @@ where
RecordType(map) => ser_seq!(ser; tag(7), RecordMap(map)),
RecordLit(map) => ser_seq!(ser; tag(8), RecordMap(map)),
UnionType(map) => ser_seq!(ser; tag(11), UnionMap(map)),
- UnionLit(l, x, map) => {
- ser_seq!(ser; tag(12), label(l), expr(x), UnionMap(map))
- }
Field(x, l) => ser_seq!(ser; tag(9), expr(x), label(l)),
BinOp(op, x, y) => {
use dhall_syntax::BinOp::*;
diff --git a/dhall/src/phase/normalize.rs b/dhall/src/phase/normalize.rs
index 2e9f258..3e45240 100644
--- a/dhall/src/phase/normalize.rs
+++ b/dhall/src/phase/normalize.rs
@@ -677,13 +677,6 @@ pub fn normalize_one_layer(expr: ExprF<Thunk, X>) -> Value {
.map(|(k, t)| (k, TypeThunk::from_thunk(t)))
.collect(),
)),
- ExprF::UnionLit(l, x, kts) => Ret::Value(UnionLit(
- l,
- x,
- kts.into_iter()
- .map(|(k, t)| (k, t.map(|t| TypeThunk::from_thunk(t))))
- .collect(),
- )),
ExprF::UnionType(kts) => Ret::Value(UnionType(
kts.into_iter()
.map(|(k, t)| (k, t.map(|t| TypeThunk::from_thunk(t))))
diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs
index 35bf3a9..4b3a03f 100644
--- a/dhall/src/phase/typecheck.rs
+++ b/dhall/src/phase/typecheck.rs
@@ -505,15 +505,6 @@ fn type_last_layer(
)?
.into_type(),
)),
- UnionLit(x, v, kvs) => {
- use std::iter::once;
- let kts = kvs
- .iter()
- .map(|(x, v)| Ok((x.clone(), v.as_ref().map(|v| v.to_type()))));
- let t = v.get_type()?.into_owned();
- let kts = kts.chain(once(Ok((x.clone(), Some(t)))));
- Ok(RetTypeOnly(tck_union_type(ctx, kts)?.to_type()))
- }
Field(r, x) => {
match &r.get_type()?.to_value() {
Value::RecordType(kts) => match kts.get(&x) {