summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2019-03-24 23:35:02 +0100
committerNadrieril2019-03-24 23:35:02 +0100
commit5663b4499b46a914ad59792220b0a6cfc24b608c (patch)
treec863a8a43b748f8fc90c03e51aa4991b401ad60e /dhall
parentc7eff8296b7e84b69184ba98deb81a7f9462e450 (diff)
Correctly namespace interpolations in dhall_expr!()
Diffstat (limited to '')
-rw-r--r--dhall/src/normalize.rs1
-rw-r--r--dhall/src/typecheck.rs2
-rw-r--r--dhall_generator/src/dhall_expr.rs38
3 files changed, 19 insertions, 22 deletions
diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs
index 2ffa5a5..1bf4b6a 100644
--- a/dhall/src/normalize.rs
+++ b/dhall/src/normalize.rs
@@ -12,7 +12,6 @@ where
S: fmt::Debug,
A: fmt::Debug,
{
- use dhall_core::BinOp::*;
use dhall_core::Builtin::*;
use dhall_core::Expr::*;
let f = rc(Builtin(b));
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index 32ffe0e..f21721d 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -115,8 +115,6 @@ where
fn type_of_builtin<S>(b: Builtin) -> Rc<Expr<S, X>> {
use dhall_core::Builtin::*;
- use dhall_core::Const::*;
- use dhall_core::Expr::*;
match b {
Bool | Natural | Integer | Double | Text => dhall_expr!(Type),
List | Optional => dhall_expr!(
diff --git a/dhall_generator/src/dhall_expr.rs b/dhall_generator/src/dhall_expr.rs
index 07873bd..1eb4580 100644
--- a/dhall_generator/src/dhall_expr.rs
+++ b/dhall_generator/src/dhall_expr.rs
@@ -32,59 +32,59 @@ fn dhall_to_tokenstream(
let t = dhall_to_tokenstream_bx(t, ctx);
let b = dhall_to_tokenstream_bx(b, &ctx.insert(x.clone(), ()));
let x = label_to_tokenstream(x);
- quote! { Pi(#x, #t, #b) }
+ quote! { dhall_core::Expr::Pi(#x, #t, #b) }
}
Lam(x, t, b) => {
let t = dhall_to_tokenstream_bx(t, ctx);
let b = dhall_to_tokenstream_bx(b, &ctx.insert(x.clone(), ()));
let x = label_to_tokenstream(x);
- quote! { Lam(#x, #t, #b) }
+ quote! { dhall_core::Expr::Lam(#x, #t, #b) }
}
App(f, a) => {
let f = dhall_to_tokenstream_bx(f, ctx);
let a = vec_to_tokenstream(a, ctx);
- quote! { App(#f, #a) }
+ quote! { dhall_core::Expr::App(#f, #a) }
}
Const(c) => {
let c = const_to_tokenstream(*c);
- quote! { Const(#c) }
+ quote! { dhall_core::Expr::Const(#c) }
}
Builtin(b) => {
let b = builtin_to_tokenstream(*b);
- quote! { Builtin(#b) }
+ quote! { dhall_core::Expr::Builtin(#b) }
}
BinOp(o, a, b) => {
let o = binop_to_tokenstream(*o);
let a = dhall_to_tokenstream_bx(a, ctx);
let b = dhall_to_tokenstream_bx(b, ctx);
- quote! { BinOp(#o, #a, #b) }
+ quote! { dhall_core::Expr::BinOp(#o, #a, #b) }
}
NaturalLit(n) => {
- quote! { NaturalLit(#n) }
+ quote! { dhall_core::Expr::NaturalLit(#n) }
}
EmptyOptionalLit(x) => {
let x = dhall_to_tokenstream_bx(x, ctx);
- quote! { EmptyOptionalLit(#x) }
+ quote! { dhall_core::Expr::EmptyOptionalLit(#x) }
}
NEOptionalLit(x) => {
let x = dhall_to_tokenstream_bx(x, ctx);
- quote! { NEOptionalLit(#x) }
+ quote! { dhall_core::Expr::NEOptionalLit(#x) }
}
EmptyListLit(t) => {
let t = dhall_to_tokenstream_bx(t, ctx);
- quote! { EmptyListLit(#t) }
+ quote! { dhall_core::Expr::EmptyListLit(#t) }
}
NEListLit(es) => {
let es = vec_to_tokenstream(es, ctx);
- quote! { NEListLit(#es) }
+ quote! { dhall_core::Expr::NEListLit(#es) }
}
RecordType(m) => {
let m = map_to_tokenstream(m, ctx);
- quote! { RecordType(#m) }
+ quote! { dhall_core::Expr::RecordType(#m) }
}
RecordLit(m) => {
let m = map_to_tokenstream(m, ctx);
- quote! { RecordLit(#m) }
+ quote! { dhall_core::Expr::RecordLit(#m) }
}
e => unimplemented!("{:?}", e),
}
@@ -102,7 +102,7 @@ fn dhall_to_tokenstream_bx(
// Non-free variable; interpolates as itself
Some(()) => {
let s: String = s.into();
- quote! { bx(Var(V(#s.into(), #n))) }
+ quote! { dhall_core::bx(dhall_core::Expr::Var(dhall_core::V(#s.into(), #n))) }
}
// Free variable; interpolates as a rust variable
None => {
@@ -110,7 +110,7 @@ fn dhall_to_tokenstream_bx(
// TODO: insert appropriate shifts ?
let v: TokenStream = s.parse().unwrap();
quote! { {
- let x: Rc<Expr<_, _>> = #v.clone();
+ let x: dhall_core::SubExpr<_, _> = #v.clone();
x
} }
}
@@ -121,15 +121,15 @@ fn dhall_to_tokenstream_bx(
}
fn builtin_to_tokenstream(b: Builtin) -> TokenStream {
- format!("{:?}", b).parse().unwrap()
+ format!("dhall_core::Builtin::{:?}", b).parse().unwrap()
}
fn const_to_tokenstream(c: Const) -> TokenStream {
- format!("{:?}", c).parse().unwrap()
+ format!("dhall_core::Const::{:?}", c).parse().unwrap()
}
fn binop_to_tokenstream(b: BinOp) -> TokenStream {
- format!("{:?}", b).parse().unwrap()
+ format!("dhall_core::BinOp::{:?}", b).parse().unwrap()
}
fn label_to_tokenstream(l: &Label) -> TokenStream {
@@ -164,5 +164,5 @@ fn vec_to_tokenstream(
}
fn bx(x: TokenStream) -> TokenStream {
- quote! { bx(#x) }
+ quote! { dhall_core::bx(#x) }
}