-
Notifications
You must be signed in to change notification settings - Fork 10
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
Include loc in (v dir node state)
?
#5
Comments
(v dir node state)
?(v dir node state)
?
On further thought I'm not sure I can use zip-visit how I was intending, so the question above probably isn't worth considering after all. In case you wondered though: what I really need is a notion of down-state and right-state which are independent of the existing (next-)state but I can't see how to bend zip-visit to achieve that without recursion ...unless you have any good ideas? |
I'm away for a few days, but let me think on it when I get back. A concrete On further thought I'm not sure I can use zip-visit how I was intending, so In case you wondered though: what I really need is a notion of down-state — |
Okay, this is approximately what I am currently doing, without any use of zippers (I'm using datascript):
I managed to - for the most part - figure out a way to fit my datascript structure into clojure.zip/zipper but it's not pretty. If I could adapt the above to use loop & recur then I suppose I wouldn't need zip-visit at all but I don't see a way to do that either. (sorry the indentation isn't perfect, I'm not sure of the easiest way to fix it...!) |
I'd love to be able to access the loc of the node in the tree (either by extra param or meta on the node). I'm using this library to work on SQL ASTs and Relational Algebra trees. One of the steps is to verify syntactically that the SQL AST is correct. This involves a) checking attributes exist in the context, b) attributes have the correct types when used with operators such as SUM and c) filling in table names for columns which don't define them (e.g. SELECT id FROM x => SELECT x.id FROM x). A and B is best done by modifying the tree with the schema in the FROM section, check all attributes exist in the WHERE section and check all attributes exist in the SELECT section. Unfortunately doing this means that C is difficult to do as the tree has been modified away from the original AST. If I could access the loc, store it in the state of the tree then if the first syntactic pass is okay I could do a second pass over the original ast and fill in the table references using the state. What do you think? |
I've had a lot of requests for this, so it seems like a good idea. Want to take a shot at a PR for it? |
As per the title, would you accept a PR to modify
visit-node
so thatloc
is passed to the visitors i.e.(v dir loc node state)
?On another note,
(z/node loc)
is immediately repeated on line 22.Great library 👍
The text was updated successfully, but these errors were encountered: