summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2020-03-21 21:30:30 +0000
committerNadrieril2020-03-31 21:44:01 +0100
commit85e2e8ee5e83dadd05b6974ba6c951350cb97a61 (patch)
tree637043ea591206f695c5b52b6625513de782ddcf /dhall
parent110bfda418b7f1444a2d32b28c515c172a6572a2 (diff)
Introduce option builder
Diffstat (limited to 'dhall')
-rw-r--r--dhall/Cargo.toml2
-rw-r--r--dhall/src/lib.rs3
-rw-r--r--dhall/src/semantics/builtins.rs6
-rw-r--r--dhall/src/semantics/resolve/resolve.rs10
4 files changed, 15 insertions, 6 deletions
diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml
index 0ffe78b..02ec1e7 100644
--- a/dhall/Cargo.toml
+++ b/dhall/Cargo.toml
@@ -22,7 +22,7 @@ reqwest = { version = "0.10", features = ["blocking"] }
serde = "1.0"
serde_cbor = "0.9.0"
smallvec = "1.0.0"
-url = "2.1.1"
+url = "2.1"
[dev-dependencies]
pretty_assertions = "0.6.1"
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index 0f4b623..adca2de 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -72,6 +72,9 @@ impl Parsed {
pub fn resolve(self) -> Result<Resolved, Error> {
resolve::resolve(self)
}
+ pub fn skip_resolve(self) -> Result<Resolved, Error> {
+ resolve::skip_resolve(self)
+ }
/// Converts a value back to the corresponding AST expression.
pub fn to_expr(&self) -> Expr {
diff --git a/dhall/src/semantics/builtins.rs b/dhall/src/semantics/builtins.rs
index fa22bd0..6007a92 100644
--- a/dhall/src/semantics/builtins.rs
+++ b/dhall/src/semantics/builtins.rs
@@ -1,5 +1,5 @@
use crate::semantics::{
- skip_resolve, typecheck, Hir, HirKind, Nir, NirKind, NzEnv, VarEnv,
+ skip_resolve_expr, typecheck, Hir, HirKind, Nir, NirKind, NzEnv, VarEnv,
};
use crate::syntax::map::DupTreeMap;
use crate::syntax::Const::Type;
@@ -189,7 +189,7 @@ pub fn type_of_builtin(b: Builtin) -> Hir {
forall (A: Type) -> Optional A
),
};
- skip_resolve(&expr).unwrap()
+ skip_resolve_expr(&expr).unwrap()
}
// Ad-hoc macro to help construct closures
@@ -254,7 +254,7 @@ fn apply_builtin(b: Builtin, args: Vec<Nir>, env: NzEnv) -> NirKind {
DoneAsIs,
}
let make_closure = |e| {
- typecheck(&skip_resolve(&e).unwrap())
+ typecheck(&skip_resolve_expr(&e).unwrap())
.unwrap()
.eval(env.clone())
};
diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs
index 07bd06c..fe3f3a9 100644
--- a/dhall/src/semantics/resolve/resolve.rs
+++ b/dhall/src/semantics/resolve/resolve.rs
@@ -227,7 +227,7 @@ fn resolve_one_import(
}
ImportMode::Location => {
let expr = location.into_location();
- let hir = skip_resolve(&expr)?;
+ let hir = skip_resolve_expr(&expr)?;
let ty = hir.typecheck_noenv()?.ty().clone();
Ok((hir, ty))
}
@@ -333,12 +333,18 @@ pub fn resolve(parsed: Parsed) -> Result<Resolved, Error> {
resolve_with_env(&mut ImportEnv::new(), parsed)
}
-pub fn skip_resolve(expr: &Expr) -> Result<Hir, Error> {
+pub fn skip_resolve_expr(expr: &Expr) -> Result<Hir, Error> {
traverse_resolve_expr(&mut NameEnv::new(), expr, &mut |import| {
Err(ImportError::UnexpectedImport(import).into())
})
}
+pub fn skip_resolve(parsed: Parsed) -> Result<Resolved, Error> {
+ let Parsed(expr, _) = parsed;
+ let resolved =skip_resolve_expr(&expr)?;
+ Ok(Resolved(resolved))
+}
+
pub trait Canonicalize {
fn canonicalize(&self) -> Self;
}