From 08e1d8ece4314b56d64fa08595c2e043b97896d1 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 6 Apr 2020 17:19:31 +0100 Subject: Split off operations from main expr enum --- serde_dhall/src/value.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'serde_dhall') diff --git a/serde_dhall/src/value.rs b/serde_dhall/src/value.rs index d6631da..587349c 100644 --- a/serde_dhall/src/value.rs +++ b/serde_dhall/src/value.rs @@ -1,7 +1,7 @@ use std::collections::{BTreeMap, HashMap}; use dhall::semantics::{Hir, HirKind, Nir, NirKind}; -use dhall::syntax::{Builtin, Expr, ExprKind, NumKind, Span}; +use dhall::syntax::{Builtin, Expr, ExprKind, NumKind, OpKind, Span}; use crate::{Error, ErrorKind, FromDhall, Result, Sealed}; @@ -218,13 +218,14 @@ impl SimpleType { SimpleType::Integer => ExprKind::Builtin(Builtin::Integer), SimpleType::Double => ExprKind::Builtin(Builtin::Double), SimpleType::Text => ExprKind::Builtin(Builtin::Text), - SimpleType::Optional(t) => ExprKind::App( + SimpleType::Optional(t) => ExprKind::Op(OpKind::App( hir(ExprKind::Builtin(Builtin::Optional)), t.to_hir(), - ), - SimpleType::List(t) => { - ExprKind::App(hir(ExprKind::Builtin(Builtin::List)), t.to_hir()) - } + )), + SimpleType::List(t) => ExprKind::Op(OpKind::App( + hir(ExprKind::Builtin(Builtin::List)), + t.to_hir(), + )), SimpleType::Record(kts) => ExprKind::RecordType( kts.iter() .map(|(k, t)| (k.as_str().into(), t.to_hir())) -- cgit v1.2.3 From fff4c46e09d4edf25eba737f4d71bfdb1dbf4a82 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 6 Apr 2020 22:11:54 +0100 Subject: Extract operation-related code to a new module --- serde_dhall/src/value.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'serde_dhall') diff --git a/serde_dhall/src/value.rs b/serde_dhall/src/value.rs index 587349c..e8f333e 100644 --- a/serde_dhall/src/value.rs +++ b/serde_dhall/src/value.rs @@ -1,7 +1,8 @@ use std::collections::{BTreeMap, HashMap}; +use dhall::operations::OpKind; use dhall::semantics::{Hir, HirKind, Nir, NirKind}; -use dhall::syntax::{Builtin, Expr, ExprKind, NumKind, OpKind, Span}; +use dhall::syntax::{Builtin, Expr, ExprKind, NumKind, Span}; use crate::{Error, ErrorKind, FromDhall, Result, Sealed}; -- cgit v1.2.3 From 56efd2ac39149d8652bd625fbf0679c10823b137 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 6 Apr 2020 22:24:15 +0100 Subject: Move BinOp and Builtin definitions in the relevant module --- serde_dhall/src/value.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'serde_dhall') diff --git a/serde_dhall/src/value.rs b/serde_dhall/src/value.rs index e8f333e..03cfdba 100644 --- a/serde_dhall/src/value.rs +++ b/serde_dhall/src/value.rs @@ -1,8 +1,9 @@ use std::collections::{BTreeMap, HashMap}; +use dhall::builtins::Builtin; use dhall::operations::OpKind; use dhall::semantics::{Hir, HirKind, Nir, NirKind}; -use dhall::syntax::{Builtin, Expr, ExprKind, NumKind, Span}; +use dhall::syntax::{Expr, ExprKind, NumKind, Span}; use crate::{Error, ErrorKind, FromDhall, Result, Sealed}; -- cgit v1.2.3