diff options
author | Nadrieril | 2019-03-08 18:17:22 +0100 |
---|---|---|
committer | Nadrieril | 2019-03-08 18:19:47 +0100 |
commit | 78a0c10a4595683c034b8d3617f55c88cea2aa3c (patch) | |
tree | bfb82c395f6a7f81e650535197665ad419d9e100 /dhall_generator/src | |
parent | 7f9d988a3e0555123030f48f3759216ef2e14ec3 (diff) |
Slowly propagate the new type parameter throughout the codebase
Diffstat (limited to 'dhall_generator/src')
-rw-r--r-- | dhall_generator/src/lib.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/dhall_generator/src/lib.rs b/dhall_generator/src/lib.rs index 1cc62d0..7f2e295 100644 --- a/dhall_generator/src/lib.rs +++ b/dhall_generator/src/lib.rs @@ -4,8 +4,6 @@ use dhall_core::*; use proc_macro2::Literal; use proc_macro2::TokenStream; use quote::quote; -use std::fmt::Debug; -use std::hash::Hash; #[proc_macro] pub fn dhall(input: proc_macro::TokenStream) -> proc_macro::TokenStream { @@ -20,7 +18,7 @@ pub fn dhall(input: proc_macro::TokenStream) -> proc_macro::TokenStream { // Returns an expression of type Expr<_, _>. Expects input variables // to be of type Box<Expr<_, _>> (future-proof for structural sharing). -fn dhall_to_tokenstream<L: Eq + Hash + Clone + Debug + Into<String>>( +fn dhall_to_tokenstream<L: StringLike>( expr: &Expr_<L, X, X>, ctx: &Context<L, ()>, ) -> TokenStream { @@ -34,7 +32,7 @@ fn dhall_to_tokenstream<L: Eq + Hash + Clone + Debug + Into<String>>( let t = dhall_to_tokenstream_bx(t, ctx); let b = dhall_to_tokenstream_bx(b, &ctx.insert(x.clone(), ())); let x = Literal::string(&x.clone().into()); - quote! { Lam(#x, #t, #b) } + quote! { Lam(#x.to_owned().into(), #t, #b) } } App(f, a) => { let f = dhall_to_tokenstream_bx(f, ctx); @@ -76,18 +74,18 @@ fn dhall_to_tokenstream<L: Eq + Hash + Clone + Debug + Into<String>>( } // Returns an expression of type Box<Expr<_, _>> -fn dhall_to_tokenstream_bx<L: Eq + Hash + Clone + Debug + Into<String>>( +fn dhall_to_tokenstream_bx<L: StringLike>( expr: &Expr_<L, X, X>, ctx: &Context<L, ()>, ) -> TokenStream { use dhall_core::Expr_::*; match expr { Var(V(s, n)) => { - match ctx.lookup(s.clone(), *n) { + match ctx.lookup(&s, *n) { // Non-free variable; interpolates as itself Some(()) => { let s: String = s.clone().into(); - quote! { bx(Var(V(#s, #n))) } + quote! { bx(Var(V(#s.to_owned().into(), #n))) } } // Free variable; interpolates as a rust variable None => { @@ -95,7 +93,7 @@ fn dhall_to_tokenstream_bx<L: Eq + Hash + Clone + Debug + Into<String>>( // TODO: insert appropriate shifts ? let v: TokenStream = s.parse().unwrap(); quote! { { - let x: Box<Expr<_, _>> = #v.clone(); + let x: Box<Expr_<_, _, _>> = #v.clone(); x } } } |