summaryrefslogtreecommitdiff
path: root/dhall_core
diff options
context:
space:
mode:
Diffstat (limited to 'dhall_core')
-rw-r--r--dhall_core/src/core.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs
index 9c96b2a..9f4beb3 100644
--- a/dhall_core/src/core.rs
+++ b/dhall_core/src/core.rs
@@ -257,6 +257,8 @@ pub enum Builtin {
Text,
List,
Optional,
+ OptionalSome,
+ OptionalNone,
NaturalBuild,
NaturalFold,
NaturalIsZero,
@@ -462,13 +464,19 @@ impl<S, A: Display> Expr<S, A> {
Ok(())
}
&OptionalLit(ref t, ref es) => {
- fmt_list("[", "]", es, f, |e, f| e.fmt(f))?;
- match t {
- Some(t) => {
- write!(f, " : Optional ")?;
- t.fmt_e(f)?
+ match es.iter().next() {
+ None => {
+ write!(f, "None ")?;
+ t.as_ref().unwrap().fmt_e(f)?;
+ }
+ Some(e) => {
+ write!(f, "Some ")?;
+ e.fmt_e(f)?;
+ if let Some(t) = t {
+ write!(f, " : Optional ")?;
+ t.fmt_e(f)?;
+ }
}
- None => {}
}
Ok(())
}
@@ -624,6 +632,8 @@ impl Display for Builtin {
Text => "Text",
List => "List",
Optional => "Optional",
+ OptionalSome => "Some",
+ OptionalNone => "None",
NaturalBuild => "Natural/build",
NaturalFold => "Natural/fold",
NaturalIsZero => "Natural/isZero",
@@ -659,6 +669,8 @@ impl Builtin {
"Text" => Some(Text),
"List" => Some(List),
"Optional" => Some(Optional),
+ "Some" => Some(OptionalSome),
+ "None" => Some(OptionalNone),
"Natural/build" => Some(NaturalBuild),
"Natural/fold" => Some(NaturalFold),
"Natural/isZero" => Some(NaturalIsZero),