summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dhall/src/expr.rs15
-rw-r--r--dhall/src/typecheck.rs2
2 files changed, 16 insertions, 1 deletions
diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs
index 9e89e3a..7c62a33 100644
--- a/dhall/src/expr.rs
+++ b/dhall/src/expr.rs
@@ -120,6 +120,9 @@ impl<'a> Normalized<'a> {
pub(crate) fn into_expr(self) -> SubExpr<X, X> {
self.0
}
+ pub(crate) fn unnote<'b>(self) -> Normalized<'b> {
+ Normalized(self.0, self.1, PhantomData)
+ }
pub(crate) fn into_type(self) -> Type<'a> {
Type(match self.0.as_ref() {
ExprF::Const(c) => TypeInternal::Const(*c),
@@ -128,6 +131,18 @@ impl<'a> Normalized<'a> {
}
}
+#[doc(hidden)]
+impl<'a> Type<'a> {
+ pub(crate) fn unnote<'b>(self) -> Type<'b> {
+ use TypeInternal::*;
+ Type(match self.0 {
+ Expr(e) => Expr(Box::new(e.unnote())),
+ Const(c) => Const(c),
+ SuperType => SuperType,
+ })
+ }
+}
+
impl<'a> SimpleType<'a> {
pub(crate) fn into_type(self) -> Type<'a> {
Normalized(self.0, Some(Type::const_type()), PhantomData).into_type()
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index 195628b..c8929fe 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -22,7 +22,7 @@ impl<'a> Resolved<'a> {
ty: &Type,
) -> Result<Typed<'static>, TypeError> {
let expr: SubExpr<_, _> = self.0.unnote();
- let ty: SubExpr<_, _> = ty.as_normalized()?.as_expr().absurd();
+ let ty: SubExpr<_, _> = ty.clone().unnote().embed()?;
type_of(dhall::subexpr!(expr: ty))
}
/// Pretends this expression has been typechecked. Use with care.