summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall/src/dhall_type.rs60
-rw-r--r--dhall/src/lib.rs3
2 files changed, 32 insertions, 31 deletions
diff --git a/dhall/src/dhall_type.rs b/dhall/src/dhall_type.rs
index 8abef32..6b0e06e 100644
--- a/dhall/src/dhall_type.rs
+++ b/dhall/src/dhall_type.rs
@@ -2,76 +2,76 @@ use dhall_core::*;
use dhall_generator::*;
#[derive(Debug, Clone)]
-pub enum DhallConversionError {}
+pub enum ConversionError {}
-pub trait DhallType: Sized {
- fn dhall_type() -> DhallExpr;
+pub trait Type {
+ fn get_type() -> DhallExpr;
// fn as_dhall(&self) -> DhallExpr;
// fn from_dhall(e: DhallExpr) -> Result<Self, DhallConversionError>;
}
-impl DhallType for bool {
- fn dhall_type() -> DhallExpr {
+impl Type for bool {
+ fn get_type() -> DhallExpr {
dhall_expr!(Bool)
}
}
-impl DhallType for Natural {
- fn dhall_type() -> DhallExpr {
+impl Type for Natural {
+ fn get_type() -> DhallExpr {
dhall_expr!(Natural)
}
}
-impl DhallType for Integer {
- fn dhall_type() -> DhallExpr {
+impl Type for Integer {
+ fn get_type() -> DhallExpr {
dhall_expr!(Integer)
}
}
-impl DhallType for String {
- fn dhall_type() -> DhallExpr {
+impl Type for String {
+ fn get_type() -> DhallExpr {
dhall_expr!(Text)
}
}
-impl<A: DhallType, B: DhallType> DhallType for (A, B) {
- fn dhall_type() -> DhallExpr {
- let ta = A::dhall_type();
- let tb = B::dhall_type();
+impl<A: Type, B: Type> Type for (A, B) {
+ fn get_type() -> DhallExpr {
+ let ta = A::get_type();
+ let tb = B::get_type();
dhall_expr!({ _1: ta, _2: tb })
}
}
-impl<T: DhallType> DhallType for Option<T> {
- fn dhall_type() -> DhallExpr {
- let t = T::dhall_type();
+impl<T: Type> Type for Option<T> {
+ fn get_type() -> DhallExpr {
+ let t = T::get_type();
dhall_expr!(Optional t)
}
}
-impl<T: DhallType> DhallType for Vec<T> {
- fn dhall_type() -> DhallExpr {
- let t = T::dhall_type();
+impl<T: Type> Type for Vec<T> {
+ fn get_type() -> DhallExpr {
+ let t = T::get_type();
dhall_expr!(List t)
}
}
-impl<'a, T: DhallType> DhallType for &'a T {
- fn dhall_type() -> DhallExpr {
- T::dhall_type()
+impl<'a, T: Type> Type for &'a T {
+ fn get_type() -> DhallExpr {
+ T::get_type()
}
}
-impl<T> DhallType for std::marker::PhantomData<T> {
- fn dhall_type() -> DhallExpr {
+impl<T> Type for std::marker::PhantomData<T> {
+ fn get_type() -> DhallExpr {
dhall_expr!({})
}
}
-impl<T: DhallType, E: DhallType> DhallType for Result<T, E> {
- fn dhall_type() -> DhallExpr {
- let tt = T::dhall_type();
- let te = E::dhall_type();
+impl<T: Type, E: Type> Type for Result<T, E> {
+ fn get_type() -> DhallExpr {
+ let tt = T::get_type();
+ let te = E::get_type();
dhall_expr!(< Ok: tt | Err: te>)
}
}
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index c0c1d6f..0270103 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -13,7 +13,8 @@ pub mod binary;
mod dhall_type;
pub mod imports;
pub mod typecheck;
-pub use dhall_type::*;
+pub use crate::dhall_type::*;
+pub use dhall_generator::Type;
pub use crate::imports::*;