summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
authorNadrieril2019-04-16 18:04:22 +0200
committerNadrieril2019-04-16 18:04:22 +0200
commit1cb13e7d75035fc1e7fcea76f57847f8dbbbac87 (patch)
tree94fd8d286e77b157dd5051010cbeac77ff926ef5 /dhall
parentba26169d47d42a8f50d30f29f699edb61a4b3759 (diff)
Remove one more instance of duplicate typechecking
Diffstat (limited to 'dhall')
-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.