Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traversal over immediate subexpressions and the embedded values #2302

Merged
merged 5 commits into from
Sep 19, 2021

Conversation

mmhat
Copy link
Collaborator

@mmhat mmhat commented Sep 18, 2021

This PR adds a variant of Dhall.Core.subExpressions which allows you to map over the embedded values simultaneously.
It is useful when you need to work with the AST directly. Specifically, it enables functions like:

traverseExpr :: Monad m => (Expr Src Void -> m (Maybe a)) -> Expr Src Void -> m (Expr Src a)
traverseExpr f expr = do
    mx <- f expr
    case mx of
        Nothing -> subExpressionsWith absurd (traverseExpr f) expr
        Just x -> pure $ Dhall.Core.Embed x

@Gabriella439 Gabriella439 merged commit ab64a9d into dhall-lang:master Sep 19, 2021
@mmhat mmhat deleted the traverse-subexpressions-with branch September 20, 2021 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants