diff options
author | Nadrieril | 2019-04-10 22:32:07 +0200 |
---|---|---|
committer | Nadrieril | 2019-04-10 22:32:07 +0200 |
commit | 7740ec004c6d7e073358bf2be00b6c0006e4dd06 (patch) | |
tree | 8c7658d71fc0fcc5158ffe028bb6a9c10701f150 /dhall/src/typecheck.rs | |
parent | 88ac184e7e967c4a5e257c91598f647b8294d71c (diff) |
Allow providing type for typechecking in API
Diffstat (limited to 'dhall/src/typecheck.rs')
-rw-r--r-- | dhall/src/typecheck.rs | 5 |
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) |