Fork me on GitHub

I'm curious what you guys think about enhancing the m/$ operator to avoid subtrees matching a pattern. I have a tree that contains information at one semantic level that I'd like to use to rewrite all the nodes at that same semantic level. It would be convenient to use m/$ to match all the nodes at that level but it traverses into lower levels and, thus, ends up matching too much.


Could you share a simplified example? (or the real one if you want)


An example would be great but, to summarize, are you asking if the operator can do a top down traversal and stop once a match has been made?


Yep. That's exactly what I'm looking for.


I can provide an example of what I'm trying to do this weekend


@U06MDAPTP I'm not entirely sure we're on the same page. I'd like the operator to do a top traversal matching everything for p1 and stop when it reaches p2


(top-down match_p stop_p)

👍 3

I need to think about this a bit more because I would like to have this model work in both directions e.g. the dual of this, I think, would be to construct a tree.


that would be pretty cool


In the mean time I know we can fill in the blanks with something that does what you’re looking for. There are a few thing ahead in the queue though.


I'm using meander to parse honeysql and rewrite it. Currently, I'm avoiding generating an AST. But, eventually, I'm going to need to convert between an AST and honeysql. Your dual top-down operator could be very handy for this, I imagine


It seems like the dual would be grow a tree with the node pattern until it matches the stop pattern, however, there needs to be a notion of where the children go.


This is something that needs thought anyway, it was bound to come up.


Are you able to use the strategy combinators in the mean time?


There is m*/top-down-while


I haven't touched the strategy stuff yet. That's a this weekend project 🙂


Sure. My hope is that, eventually, what is in the main namespace, the interpreter work, and the strategies can all be joined together in a super nova of fun times 😛


This is my immortality project. 🙂


I have to say, meander has been a game changer for me. The bulk of my application code is generating SQL statements from fragments of SQL that know how to project various bits of data. SQL is a bear to compose but meander has given me a way of taming it without completely losing my mind.

👍 3

That’s really great to hear. If you’re ever open to it — and there is zero pressure when I say this — you could always drop some snippets of what you’re doing the in the cookbook etc.


That’s a space for anyone and everyone.


Yep. That's on my to-do list