diff options
Diffstat (limited to '')
-rw-r--r-- | dhall/src/phase/typecheck.rs | 12 | ||||
-rw-r--r-- | dhall_syntax/src/core/expr.rs | 4 |
2 files changed, 7 insertions, 9 deletions
diff --git a/dhall/src/phase/typecheck.rs b/dhall/src/phase/typecheck.rs index 2dc97bb..66f5b5b 100644 --- a/dhall/src/phase/typecheck.rs +++ b/dhall/src/phase/typecheck.rs @@ -328,10 +328,7 @@ pub(crate) fn mktype( } pub(crate) fn builtin_to_type(b: Builtin) -> Result<Type, TypeError> { - mktype( - &TypecheckContext::new(), - SubExpr::from_expr_no_note(ExprF::Builtin(b)), - ) + mktype(&TypecheckContext::new(), SubExpr::from_builtin(b)) } /// Intermediary return type @@ -390,15 +387,12 @@ fn type_with( return type_with(&ctx.insert_value(x, v.clone())?, e.clone()); } OldOptionalLit(None, t) => { - let none = SubExpr::from_expr_no_note(ExprF::Builtin( - Builtin::OptionalNone, - )); + let none = SubExpr::from_builtin(Builtin::OptionalNone); let e = e.rewrap(App(none, t.clone())); return type_with(ctx, e); } OldOptionalLit(Some(x), t) => { - let optional = - SubExpr::from_expr_no_note(ExprF::Builtin(Builtin::Optional)); + let optional = SubExpr::from_builtin(Builtin::Optional); let x = x.rewrap(SomeLit(x.clone())); let t = t.rewrap(App(optional, t.clone())); let e = e.rewrap(Annot(x, t)); diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index 3b73d88..c509bae 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -338,6 +338,10 @@ impl<N, E> SubExpr<N, E> { SubExpr(Rc::new((x, None))) } + pub fn from_builtin(b: Builtin) -> Self { + SubExpr::from_expr_no_note(ExprF::Builtin(b)) + } + pub fn rewrap<E2>(&self, x: Expr<N, E2>) -> SubExpr<N, E2> where N: Clone, |