summaryrefslogtreecommitdiff
path: root/dhall_core/src/core.rs
diff options
context:
space:
mode:
authorNadrieril2019-03-18 05:27:17 +0100
committerNadrieril2019-03-18 05:27:17 +0100
commit92ea98da2f89348c3dfdc7d49594a4d876d06ba2 (patch)
tree90de90c45a361538d50d875fa5543fbd4b6ad9d8 /dhall_core/src/core.rs
parent5c33165e95eb264fa9d305c097b183f6622aad03 (diff)
Split List literal between empty and non-empty
Diffstat (limited to 'dhall_core/src/core.rs')
-rw-r--r--dhall_core/src/core.rs25
1 files changed, 12 insertions, 13 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs
index a3236eb..722506b 100644
--- a/dhall_core/src/core.rs
+++ b/dhall_core/src/core.rs
@@ -307,8 +307,10 @@ pub enum Expr<Note, Embed> {
DoubleLit(Double),
/// `TextLit t ~ t`
TextLit(InterpolatedText<Note, Embed>),
- /// `ListLit t [x, y, z] ~ [x, y, z] : List t`
- ListLit(Option<SubExpr<Note, Embed>>, Vec<SubExpr<Note, Embed>>),
+ /// [] : List t`
+ EmptyListLit(SubExpr<Note, Embed>),
+ /// [x, y, z]
+ NEListLit(Vec<SubExpr<Note, Embed>>),
/// `OptionalLit t [e] ~ [e] : Optional t`
/// `OptionalLit t [] ~ [] : Optional t`
OptionalLit(Option<SubExpr<Note, Embed>>, Option<SubExpr<Note, Embed>>),
@@ -543,16 +545,12 @@ impl<S, A: Display> Expr<S, A> {
write!(f, ") → ")?;
d.fmt_b(f)
}
- &ListLit(ref t, ref es) => {
- fmt_list("[", "]", es, f, |e, f| e.fmt(f))?;
- match t {
- Some(t) => {
- write!(f, " : List ")?;
- t.fmt_e(f)?
- }
- None => {}
- }
- Ok(())
+ &EmptyListLit(ref t) => {
+ write!(f, "[] : List ")?;
+ t.fmt_e(f)
+ }
+ &NEListLit(ref es) => {
+ fmt_list("[", "]", es, f, |e, f| e.fmt(f))
}
&OptionalLit(ref t, ref es) => {
match es {
@@ -902,7 +900,8 @@ where
DoubleLit(n) => DoubleLit(*n),
TextLit(t) => TextLit(t.map(&map)),
BinOp(o, x, y) => BinOp(*o, map(x), map(y)),
- ListLit(t, es) => ListLit(opt(t), vec(es)),
+ EmptyListLit(t) => EmptyListLit(map(t)),
+ NEListLit(es) => NEListLit(vec(es)),
OptionalLit(t, es) => OptionalLit(opt(t), opt(es)),
Record(kts) => Record(btmap(kts)),
RecordLit(kvs) => RecordLit(btmap(kvs)),