From a506632b27b287d1bf898e2f77ae09a56902474c Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 20 Aug 2019 17:08:01 +0200 Subject: Naming tweaks --- serde_dhall/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'serde_dhall') diff --git a/serde_dhall/src/lib.rs b/serde_dhall/src/lib.rs index cef11dd..4171fab 100644 --- a/serde_dhall/src/lib.rs +++ b/serde_dhall/src/lib.rs @@ -169,14 +169,12 @@ pub mod value { } pub(crate) fn make_optional_type(t: Value) -> Self { Self::make_simple_type( - DhallValueF::from_builtin(Builtin::Optional) - .app_value(t.to_value()), + DhallValueF::from_builtin(Builtin::Optional).app(t.to_value()), ) } pub(crate) fn make_list_type(t: Value) -> Self { Self::make_simple_type( - DhallValueF::from_builtin(Builtin::List) - .app_value(t.to_value()), + DhallValueF::from_builtin(Builtin::List).app(t.to_value()), ) } // Made public for the StaticType derive macro -- cgit v1.2.3 From 4f1f37cfc115510500e83d2dfbfa8ed7ddeae74a Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 20 Aug 2019 18:03:59 +0200 Subject: Introduce a new enum to store either a Value or a ValueF --- serde_dhall/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'serde_dhall') diff --git a/serde_dhall/src/lib.rs b/serde_dhall/src/lib.rs index 4171fab..e2449de 100644 --- a/serde_dhall/src/lib.rs +++ b/serde_dhall/src/lib.rs @@ -169,12 +169,16 @@ pub mod value { } pub(crate) fn make_optional_type(t: Value) -> Self { Self::make_simple_type( - DhallValueF::from_builtin(Builtin::Optional).app(t.to_value()), + DhallValueF::from_builtin(Builtin::Optional) + .app(t.to_value()) + .into_whnf(), ) } pub(crate) fn make_list_type(t: Value) -> Self { Self::make_simple_type( - DhallValueF::from_builtin(Builtin::List).app(t.to_value()), + DhallValueF::from_builtin(Builtin::List) + .app(t.to_value()) + .into_whnf(), ) } // Made public for the StaticType derive macro -- cgit v1.2.3 From 8c1ffc5b68489be4694fff922ca48afeb0d45fc4 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 20 Aug 2019 23:02:56 +0200 Subject: Move type construction fns from serde_dhall to dhall --- serde_dhall/src/lib.rs | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) (limited to 'serde_dhall') diff --git a/serde_dhall/src/lib.rs b/serde_dhall/src/lib.rs index e2449de..ce3468f 100644 --- a/serde_dhall/src/lib.rs +++ b/serde_dhall/src/lib.rs @@ -124,8 +124,6 @@ pub use value::Value; // A Dhall value. pub mod value { - use dhall::core::value::Value as DhallValue; - use dhall::core::valuef::ValueF as DhallValueF; use dhall::phase::{NormalizedSubExpr, Parsed, Typed}; use dhall_syntax::Builtin; @@ -153,50 +151,32 @@ pub mod value { pub(crate) fn to_expr(&self) -> NormalizedSubExpr { self.0.to_expr() } - pub(crate) fn to_value(&self) -> DhallValue { - self.0.to_value() - } pub(crate) fn as_typed(&self) -> &Typed { &self.0 } - /// Assumes that the given value has type `Type`. - pub(crate) fn make_simple_type(v: DhallValueF) -> Self { - Value(Typed::from_valuef_and_type(v, Typed::const_type())) - } pub(crate) fn make_builtin_type(b: Builtin) -> Self { - Self::make_simple_type(DhallValueF::from_builtin(b)) + Value(Typed::make_builtin_type(b)) } pub(crate) fn make_optional_type(t: Value) -> Self { - Self::make_simple_type( - DhallValueF::from_builtin(Builtin::Optional) - .app(t.to_value()) - .into_whnf(), - ) + Value(Typed::make_optional_type(t.0)) } pub(crate) fn make_list_type(t: Value) -> Self { - Self::make_simple_type( - DhallValueF::from_builtin(Builtin::List) - .app(t.to_value()) - .into_whnf(), - ) + Value(Typed::make_list_type(t.0)) } // Made public for the StaticType derive macro #[doc(hidden)] pub fn make_record_type( kts: impl Iterator, ) -> Self { - Self::make_simple_type(DhallValueF::RecordType( - kts.map(|(k, t)| (k.into(), t.to_value())).collect(), - )) + Value(Typed::make_record_type(kts.map(|(k, t)| (k, t.0)))) } #[doc(hidden)] pub fn make_union_type( kts: impl Iterator)>, ) -> Self { - Self::make_simple_type(DhallValueF::UnionType( - kts.map(|(k, t)| (k.into(), t.map(|t| t.to_value()))) - .collect(), + Value(Typed::make_union_type( + kts.map(|(k, t)| (k, t.map(|t| t.0))), )) } } -- cgit v1.2.3