summaryrefslogtreecommitdiff
path: root/dhall/src/typecheck.rs
diff options
context:
space:
mode:
authorNadrieril2019-04-10 22:32:07 +0200
committerNadrieril2019-04-10 22:32:07 +0200
commit7740ec004c6d7e073358bf2be00b6c0006e4dd06 (patch)
tree8c7658d71fc0fcc5158ffe028bb6a9c10701f150 /dhall/src/typecheck.rs
parent88ac184e7e967c4a5e257c91598f647b8294d71c (diff)
Allow providing type for typechecking in API
Diffstat (limited to '')
-rw-r--r--dhall/src/typecheck.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index f51f1b6..9741e65 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -13,6 +13,11 @@ impl Resolved {
pub fn typecheck(self) -> Result<Typed, TypeError<X>> {
type_of(self.0.clone())
}
+ pub fn typecheck_with(self, ty: &Type) -> Result<Typed, TypeError<X>> {
+ let expr: SubExpr<_, _> = self.0.clone();
+ let ty: SubExpr<_, _> = ty.as_normalized()?.as_expr().clone();
+ type_of(dhall::subexpr!(expr: ty))
+ }
/// Pretends this expression has been typechecked. Use with care.
pub fn skip_typecheck(self) -> Typed {
Typed(self.0, UNTYPE)