diff options
author | Nadrieril | 2019-04-06 17:50:47 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-06 17:50:47 +0200 |
commit | d9b4bd8d4019ca9ab999c0c4657663604158101c (patch) | |
tree | 15b90ab300995a7dd92c469b903d2fc8f6d57888 /dhall | |
parent | 9741e3280ed03920732430e7994e1f8482c9ddd6 (diff) |
s/Type/StaticType/
Diffstat (limited to 'dhall')
-rw-r--r-- | dhall/src/dhall_type.rs | 22 | ||||
-rw-r--r-- | dhall/src/lib.rs | 3 | ||||
-rw-r--r-- | dhall/tests/dhall_type.rs | 14 |
3 files changed, 19 insertions, 20 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<Self, DhallConversionError>; } -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<A: Type, B: Type> Type for (A, B) { +impl<A: StaticType, B: StaticType> StaticType for (A, B) { fn get_type() -> DhallExpr { let ta = A::get_type(); let tb = B::get_type(); @@ -42,33 +42,33 @@ impl<A: Type, B: Type> Type for (A, B) { } } -impl<T: Type> Type for Option<T> { +impl<T: StaticType> StaticType for Option<T> { fn get_type() -> DhallExpr { let t = T::get_type(); dhall_expr!(Optional t) } } -impl<T: Type> Type for Vec<T> { +impl<T: StaticType> StaticType for Vec<T> { 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<T> Type for std::marker::PhantomData<T> { +impl<T> StaticType for std::marker::PhantomData<T> { fn get_type() -> DhallExpr { dhall_expr!({}) } } -impl<T: Type, E: Type> Type for Result<T, E> { +impl<T: StaticType, E: StaticType> StaticType for Result<T, E> { 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<bool>, } assert_eq!( - <A as dhall::Type>::get_type(), + <A as dhall::StaticType>::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!(<B<'static, bool>>::get_type(), A::get_type()); - #[derive(Type)] + #[derive(StaticType)] #[allow(dead_code)] struct C<T>(T, Option<String>); assert_eq!(<C<bool>>::get_type(), <(bool, Option<String>)>::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<T> { A(T), |