From d9b4bd8d4019ca9ab999c0c4657663604158101c Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 6 Apr 2019 17:50:47 +0200 Subject: s/Type/StaticType/ --- dhall/src/dhall_type.rs | 22 +++++++++++----------- dhall/src/lib.rs | 3 +-- dhall/tests/dhall_type.rs | 14 +++++++------- dhall_generator/src/dhall_type.rs | 10 +++++----- dhall_generator/src/lib.rs | 2 +- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/dhall/src/dhall_type.rs b/dhall/src/dhall_type.rs index 6b0e06e..64e07d9 100644 --- a/dhall/src/dhall_type.rs +++ b/dhall/src/dhall_type.rs @@ -4,37 +4,37 @@ use dhall_generator::*; #[derive(Debug, Clone)] pub enum ConversionError {} -pub trait Type { +pub trait StaticType { fn get_type() -> DhallExpr; // fn as_dhall(&self) -> DhallExpr; // fn from_dhall(e: DhallExpr) -> Result; } -impl Type for bool { +impl StaticType for bool { fn get_type() -> DhallExpr { dhall_expr!(Bool) } } -impl Type for Natural { +impl StaticType for Natural { fn get_type() -> DhallExpr { dhall_expr!(Natural) } } -impl Type for Integer { +impl StaticType for Integer { fn get_type() -> DhallExpr { dhall_expr!(Integer) } } -impl Type for String { +impl StaticType for String { fn get_type() -> DhallExpr { dhall_expr!(Text) } } -impl Type for (A, B) { +impl StaticType for (A, B) { fn get_type() -> DhallExpr { let ta = A::get_type(); let tb = B::get_type(); @@ -42,33 +42,33 @@ impl Type for (A, B) { } } -impl Type for Option { +impl StaticType for Option { fn get_type() -> DhallExpr { let t = T::get_type(); dhall_expr!(Optional t) } } -impl Type for Vec { +impl StaticType for Vec { fn get_type() -> DhallExpr { let t = T::get_type(); dhall_expr!(List t) } } -impl<'a, T: Type> Type for &'a T { +impl<'a, T: StaticType> StaticType for &'a T { fn get_type() -> DhallExpr { T::get_type() } } -impl Type for std::marker::PhantomData { +impl StaticType for std::marker::PhantomData { fn get_type() -> DhallExpr { dhall_expr!({}) } } -impl Type for Result { +impl StaticType for Result { fn get_type() -> DhallExpr { let tt = T::get_type(); let te = E::get_type(); diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 103fd29..5a155c8 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -16,8 +16,7 @@ pub mod typecheck; pub use crate::dhall_type::*; pub use dhall_generator::expr; pub use dhall_generator::subexpr; -pub use dhall_generator::Type; - +pub use dhall_generator::StaticType; pub use crate::imports::*; // pub struct DhallExpr(dhall_core::DhallExpr); diff --git a/dhall/tests/dhall_type.rs b/dhall/tests/dhall_type.rs index 941e3a4..ac6b5e6 100644 --- a/dhall/tests/dhall_type.rs +++ b/dhall/tests/dhall_type.rs @@ -1,5 +1,5 @@ #![feature(proc_macro_hygiene)] -use dhall::Type; +use dhall::StaticType; use dhall_generator::dhall_expr; #[test] @@ -11,18 +11,18 @@ fn test_dhall_type() { dhall_expr!({ _1: Bool, _2: Optional Text }) ); - #[derive(dhall::Type)] + #[derive(dhall::StaticType)] #[allow(dead_code)] struct A { field1: bool, field2: Option, } assert_eq!( - ::get_type(), + ::get_type(), dhall_expr!({ field1: Bool, field2: Optional Bool }) ); - #[derive(Type)] + #[derive(StaticType)] #[allow(dead_code)] struct B<'a, T: 'a> { field1: &'a T, @@ -30,12 +30,12 @@ fn test_dhall_type() { } assert_eq!(>::get_type(), A::get_type()); - #[derive(Type)] + #[derive(StaticType)] #[allow(dead_code)] struct C(T, Option); assert_eq!(>::get_type(), <(bool, Option)>::get_type()); - #[derive(Type)] + #[derive(StaticType)] #[allow(dead_code)] struct D(); assert_eq!( @@ -43,7 +43,7 @@ fn test_dhall_type() { dhall_expr!({ _1: {}, _2: Optional Text }) ); - #[derive(Type)] + #[derive(StaticType)] #[allow(dead_code)] enum E { A(T), diff --git a/dhall_generator/src/dhall_type.rs b/dhall_generator/src/dhall_type.rs index 3b1d1c9..38c871d 100644 --- a/dhall_generator/src/dhall_type.rs +++ b/dhall_generator/src/dhall_type.rs @@ -44,7 +44,7 @@ pub fn derive_for_struct( .map(|(name, ty)| { let name = dhall_core::Label::from(name); constraints.push(ty.clone()); - (name, quote!(<#ty as dhall::Type>::get_type())) + (name, quote!(<#ty as dhall::StaticType>::get_type())) }) .collect(); let record = @@ -88,7 +88,7 @@ pub fn derive_for_enum( }; let ty = ty?; constraints.push(ty.clone()); - Ok((name, quote!(<#ty as dhall::Type>::get_type()))) + Ok((name, quote!(<#ty as dhall::StaticType>::get_type()))) }) .collect::>()?; @@ -136,7 +136,7 @@ pub fn derive_type_inner( let mut local_where_clause = orig_where_clause.clone(); local_where_clause .predicates - .push(parse_quote!(#ty: dhall::Type)); + .push(parse_quote!(#ty: dhall::StaticType)); let phantoms = generics.params.iter().map(|param| match param { syn::GenericParam::Type(syn::TypeParam { ident, .. }) => { quote!(#ident) @@ -156,12 +156,12 @@ pub fn derive_type_inner( // Ensure that all the fields have a Type impl let mut where_clause = orig_where_clause.clone(); for ty in constraints.iter() { - where_clause.predicates.push(parse_quote!(#ty: dhall::Type)); + where_clause.predicates.push(parse_quote!(#ty: dhall::StaticType)); } let ident = &input.ident; let tokens = quote! { - impl #impl_generics dhall::Type for #ident #ty_generics + impl #impl_generics dhall::StaticType for #ident #ty_generics #where_clause { fn get_type() -> dhall_core::DhallExpr { #(#assertions)* diff --git a/dhall_generator/src/lib.rs b/dhall_generator/src/lib.rs index f31faa4..08ce21e 100644 --- a/dhall_generator/src/lib.rs +++ b/dhall_generator/src/lib.rs @@ -21,7 +21,7 @@ pub fn subexpr(input: TokenStream) -> TokenStream { dhall_expr::subexpr(input) } -#[proc_macro_derive(Type)] +#[proc_macro_derive(StaticType)] pub fn derive_type(input: TokenStream) -> TokenStream { dhall_type::derive_type(input) } -- cgit v1.2.3