summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall/src/expr.rs8
-rw-r--r--dhall/src/imports.rs11
-rw-r--r--dhall/src/typecheck.rs6
3 files changed, 10 insertions, 15 deletions
diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs
index 3987896..ab59ce0 100644
--- a/dhall/src/expr.rs
+++ b/dhall/src/expr.rs
@@ -23,17 +23,13 @@ macro_rules! derive_other_traits {
#[derive(Debug, Clone, Eq)]
pub struct Parsed<'a>(
- pub(crate) SubExpr<X, Import>,
+ pub(crate) SubExpr<Span<'a>, Import>,
pub(crate) ImportRoot,
- pub(crate) PhantomData<&'a ()>,
);
derive_other_traits!(Parsed);
#[derive(Debug, Clone, Eq)]
-pub struct Resolved<'a>(
- pub(crate) SubExpr<X, Normalized<'static>>,
- pub(crate) PhantomData<&'a ()>,
-);
+pub struct Resolved<'a>(pub(crate) SubExpr<Span<'a>, Normalized<'static>>);
derive_other_traits!(Resolved);
#[derive(Debug, Clone, Eq)]
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs
index cc9654a..36f0802 100644
--- a/dhall/src/imports.rs
+++ b/dhall/src/imports.rs
@@ -3,7 +3,6 @@ use crate::expr::*;
use dhall_core::*;
use std::fs::File;
use std::io::Read;
-use std::marker::PhantomData;
use std::path::Path;
use std::path::PathBuf;
@@ -50,7 +49,7 @@ fn load_import(f: &Path) -> Result<Normalized<'static>, Error> {
}
fn resolve_expr<'a>(
- Parsed(expr, root, marker): Parsed<'a>,
+ Parsed(expr, root): Parsed<'a>,
allow_imports: bool,
) -> Result<Resolved<'a>, ImportError> {
let resolve =
@@ -63,7 +62,7 @@ fn resolve_expr<'a>(
}
};
let expr = expr.as_ref().traverse_embed(&resolve)?;
- Ok(Resolved(rc(expr), marker))
+ Ok(Resolved(rc(expr)))
}
impl<'a> Parsed<'a> {
@@ -72,13 +71,13 @@ impl<'a> Parsed<'a> {
File::open(f)?.read_to_string(&mut buffer)?;
let expr = parse_expr(&*buffer)?;
let root = ImportRoot::LocalDir(f.parent().unwrap().to_owned());
- Ok(Parsed(expr, root, PhantomData))
+ Ok(Parsed(expr.unnote().note_absurd(), root))
}
pub fn parse_str(s: &'a str) -> Result<Parsed<'a>, Error> {
let expr = parse_expr(s)?;
let root = ImportRoot::LocalDir(std::env::current_dir()?);
- Ok(Parsed(expr, root, PhantomData))
+ Ok(Parsed(expr, root))
}
pub fn parse_binary_file(f: &Path) -> Result<Parsed<'a>, Error> {
@@ -86,7 +85,7 @@ impl<'a> Parsed<'a> {
File::open(f)?.read_to_end(&mut buffer)?;
let expr = crate::binary::decode(&buffer)?;
let root = ImportRoot::LocalDir(f.parent().unwrap().to_owned());
- Ok(Parsed(expr, root, PhantomData))
+ Ok(Parsed(expr.note_absurd(), root))
}
pub fn resolve(self) -> Result<Resolved<'a>, ImportError> {
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index d98095c..5a28089 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -14,19 +14,19 @@ use self::TypeMessage::*;
impl<'a> Resolved<'a> {
pub fn typecheck(self) -> Result<Typed<'static>, TypeError> {
- type_of(self.0.clone())
+ type_of(self.0.unnote())
}
pub fn typecheck_with(
self,
ty: &Type,
) -> Result<Typed<'static>, TypeError> {
- let expr: SubExpr<_, _> = self.0.clone();
+ let expr: SubExpr<_, _> = self.0.unnote();
let ty: SubExpr<_, _> = ty.as_normalized()?.as_expr().absurd();
type_of(dhall::subexpr!(expr: ty))
}
/// Pretends this expression has been typechecked. Use with care.
pub fn skip_typecheck(self) -> Typed<'a> {
- Typed(self.0, None, self.1)
+ Typed(self.0.unnote(), None, PhantomData)
}
}
impl<'a> Typed<'a> {