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

Add Dhall.Traverse #660

Merged
merged 3 commits into from Oct 26, 2018
Merged

Add Dhall.Traverse #660

merged 3 commits into from Oct 26, 2018

Conversation

ocharles
Copy link
Member

This contains subExpressions, a traversal that visits all immediate
sub-Expr's of an Expr. This is a fairly fundamental traversal, which is
extremely useful when combined with idioms from Control.Lens.Plated,
allowed for very easy rewriting of ASTs.

This contains subExpressions, a traversal that visits all immediate
sub-Expr's of an Expr. This is a fairly fundamental traversal, which is
extremely useful when combined with idioms from Control.Lens.Plated,
allowed for very easy rewriting of ASTs.
@ocharles
Copy link
Member Author

I lifted this from dhall-to-cabal as I have already found myself wanting it for the core of a dhallql experiment (I need to collect all "evaluateable queries", which is a traversal of the whole AST looking for particular nodes). I've removed the wildcard match with something more principled, which already revealed a bug in the old implementation (there was no traversal into Project or CombineTypes).

dhall.cabal Outdated
@@ -170,6 +170,7 @@ Library
Dhall.Pretty,
Dhall.Repl,
Dhall.TH,
Dhall.Traverse,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably add this to Dhall.Core. It seems like the most natural place to add optics for the Expr type

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did consider that, but it's a whopping big module. This options up a bit of potential for build parallelism, but I have no proof it actually helps. If you want it there, I'm happy to move it. I also considered claiming Dhall.Lens as it's getting into lensy territory, but I have no idea what else would show up there. Can I defer to you to make a decision?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's stick to Dhall.Core for now since it hasn't been a significant build bottleneck in my experience, yet. Usually the bottleneck is one of the Dhall.Parser.* modules

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, moving it there, and reformatting to match your style, as it seems like this will be accepted.

@Gabriella439 Gabriella439 merged commit 6fd4c83 into master Oct 26, 2018
@Gabriella439
Copy link
Collaborator

Thanks! 🙂

@Gabriella439 Gabriella439 deleted the traverse branch October 26, 2018 23:35
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