summaryrefslogtreecommitdiff
path: root/dhall_generator
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall_generator/src/derive.rs (renamed from dhall_generator/src/dhall_type.rs)16
-rw-r--r--dhall_generator/src/lib.rs12
-rw-r--r--dhall_generator/src/quote.rs (renamed from dhall_generator/src/dhall_expr.rs)3
3 files changed, 18 insertions, 13 deletions
diff --git a/dhall_generator/src/dhall_type.rs b/dhall_generator/src/derive.rs
index 3b1d1c9..159ff5c 100644
--- a/dhall_generator/src/dhall_type.rs
+++ b/dhall_generator/src/derive.rs
@@ -44,11 +44,11 @@ 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 =
- crate::dhall_expr::quote_exprf(dhall_core::ExprF::RecordType(fields));
+ crate::quote::quote_exprf(dhall_core::ExprF::RecordType(fields));
Ok(quote! { dhall_core::rc(#record) })
}
@@ -88,12 +88,12 @@ 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::<Result<_, Error>>()?;
let union =
- crate::dhall_expr::quote_exprf(dhall_core::ExprF::UnionType(variants));
+ crate::quote::quote_exprf(dhall_core::ExprF::UnionType(variants));
Ok(quote! { dhall_core::rc(#union) })
}
@@ -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,14 @@ 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..b422834 100644
--- a/dhall_generator/src/lib.rs
+++ b/dhall_generator/src/lib.rs
@@ -1,7 +1,7 @@
extern crate proc_macro;
-mod dhall_expr;
-mod dhall_type;
+mod derive;
+mod quote;
use proc_macro::TokenStream;
@@ -13,15 +13,15 @@ pub fn dhall_expr(input: TokenStream) -> TokenStream {
#[proc_macro]
pub fn expr(input: TokenStream) -> TokenStream {
- dhall_expr::expr(input)
+ quote::expr(input)
}
#[proc_macro]
pub fn subexpr(input: TokenStream) -> TokenStream {
- dhall_expr::subexpr(input)
+ quote::subexpr(input)
}
-#[proc_macro_derive(Type)]
+#[proc_macro_derive(StaticType)]
pub fn derive_type(input: TokenStream) -> TokenStream {
- dhall_type::derive_type(input)
+ derive::derive_type(input)
}
diff --git a/dhall_generator/src/dhall_expr.rs b/dhall_generator/src/quote.rs
index d0c5733..8fce89d 100644
--- a/dhall_generator/src/dhall_expr.rs
+++ b/dhall_generator/src/quote.rs
@@ -63,6 +63,9 @@ where
let a = quote_vec(a);
quote! { dhall_core::ExprF::App(#f, #a) }
}
+ Annot(x, t) => {
+ quote! { dhall_core::ExprF::Annot(#x, #t) }
+ }
Const(c) => {
let c = quote_const(c);
quote! { dhall_core::ExprF::Const(#c) }