summaryrefslogtreecommitdiff
path: root/dhall/src/traits
diff options
context:
space:
mode:
authorNadrieril2019-04-10 22:32:07 +0200
committerNadrieril2019-04-10 22:32:07 +0200
commit7740ec004c6d7e073358bf2be00b6c0006e4dd06 (patch)
tree8c7658d71fc0fcc5158ffe028bb6a9c10701f150 /dhall/src/traits
parent88ac184e7e967c4a5e257c91598f647b8294d71c (diff)
Allow providing type for typechecking in API
Diffstat (limited to 'dhall/src/traits')
-rw-r--r--dhall/src/traits/deserialize.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/dhall/src/traits/deserialize.rs b/dhall/src/traits/deserialize.rs
index ad4cde6..5271a65 100644
--- a/dhall/src/traits/deserialize.rs
+++ b/dhall/src/traits/deserialize.rs
@@ -24,8 +24,11 @@ impl<'a> Deserialize<'a> for Resolved {
impl<'a> Deserialize<'a> for Typed {
/// Parses, resolves and typechecks the provided string.
fn from_str(s: &'a str, ty: Option<&Type>) -> Result<Self> {
- // TODO: compare with provided type
- Ok(Resolved::from_str(s, ty)?.typecheck()?)
+ let resolved = Resolved::from_str(s, ty)?;
+ match ty {
+ None => Ok(resolved.typecheck()?),
+ Some(t) => Ok(resolved.typecheck_with(t)?),
+ }
}
}