diff options
Diffstat (limited to '')
-rw-r--r-- | dhall/src/phase/mod.rs | 4 | ||||
-rw-r--r-- | dhall_syntax/src/core/expr.rs | 25 | ||||
-rw-r--r-- | dhall_syntax/src/core/visitor.rs | 11 |
3 files changed, 24 insertions, 16 deletions
diff --git a/dhall/src/phase/mod.rs b/dhall/src/phase/mod.rs index 2c5505c..337ce3d 100644 --- a/dhall/src/phase/mod.rs +++ b/dhall/src/phase/mod.rs @@ -16,8 +16,8 @@ pub(crate) mod parse; pub(crate) mod resolve; pub(crate) mod typecheck; -pub type ParsedExpr = Expr<!>; -pub type DecodedExpr = Expr<!>; +pub type ParsedExpr = Expr<Normalized>; +pub type DecodedExpr = Expr<Normalized>; pub type ResolvedExpr = Expr<Normalized>; pub type NormalizedExpr = Expr<Normalized>; diff --git a/dhall_syntax/src/core/expr.rs b/dhall_syntax/src/core/expr.rs index eeee4d8..f46cafb 100644 --- a/dhall_syntax/src/core/expr.rs +++ b/dhall_syntax/src/core/expr.rs @@ -313,21 +313,25 @@ impl<SE, E> ExprF<SE, E> { } impl<E> RawExpr<E> { - pub fn traverse_resolve<E2, Err>( + pub fn traverse_resolve<Err>( &self, - visit_import: impl FnMut(&Import<Expr<E2>>) -> Result<E2, Err>, - ) -> Result<RawExpr<E2>, Err> { + visit_import: impl FnMut(&Import<Expr<E>>) -> Result<E, Err>, + ) -> Result<RawExpr<E>, Err> + where + E: Clone, + { self.traverse_resolve_with_visitor(&mut visitor::ResolveVisitor( visit_import, )) } - pub(crate) fn traverse_resolve_with_visitor<E2, Err, F1>( + pub(crate) fn traverse_resolve_with_visitor<Err, F1>( &self, visitor: &mut visitor::ResolveVisitor<F1>, - ) -> Result<RawExpr<E2>, Err> + ) -> Result<RawExpr<E>, Err> where - F1: FnMut(&Import<Expr<E2>>) -> Result<E2, Err>, + E: Clone, + F1: FnMut(&Import<Expr<E>>) -> Result<E, Err>, { match self { ExprF::BinOp(BinOp::ImportAlt, l, r) => l @@ -368,10 +372,13 @@ impl<E> Expr<E> { } impl<E> Expr<E> { - pub fn traverse_resolve<E2, Err>( + pub fn traverse_resolve<Err>( &self, - visit_import: impl FnMut(&Import<Expr<E2>>) -> Result<E2, Err>, - ) -> Result<Expr<E2>, Err> { + visit_import: impl FnMut(&Import<Expr<E>>) -> Result<E, Err>, + ) -> Result<Expr<E>, Err> + where + E: Clone, + { Ok(self.rewrap(self.as_ref().traverse_resolve(visit_import)?)) } } diff --git a/dhall_syntax/src/core/visitor.rs b/dhall_syntax/src/core/visitor.rs index 435771e..addb282 100644 --- a/dhall_syntax/src/core/visitor.rs +++ b/dhall_syntax/src/core/visitor.rs @@ -250,24 +250,25 @@ where pub struct ResolveVisitor<F1>(pub F1); -impl<'a, 'b, E, E2, Err, F1> ExprFFallibleVisitor<'a, Expr<E>, Expr<E2>, E, E2> +impl<'a, 'b, E, Err, F1> ExprFFallibleVisitor<'a, Expr<E>, Expr<E>, E, E> for &'b mut ResolveVisitor<F1> where - F1: FnMut(&Import<Expr<E2>>) -> Result<E2, Err>, + E: Clone, + F1: FnMut(&Import<Expr<E>>) -> Result<E, Err>, { type Error = Err; fn visit_subexpr( &mut self, subexpr: &'a Expr<E>, - ) -> Result<Expr<E2>, Self::Error> { + ) -> Result<Expr<E>, Self::Error> { Ok(subexpr.rewrap( subexpr .as_ref() .traverse_resolve_with_visitor(&mut **self)?, )) } - fn visit_embed(self, _embed: &'a E) -> Result<E2, Self::Error> { - unimplemented!() + fn visit_embed(self, embed: &'a E) -> Result<E, Self::Error> { + Ok(embed.clone()) } } |