Fork me on GitHub
#meander
<
2020-12-11
>
markaddleman15:12:06

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.

Jimmy Miller16:12:06

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

noprompt20:12:22

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?

markaddleman20:12:44

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

markaddleman20:12:09

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

markaddleman20:12:03

@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

noprompt20:12:21

(top-down match_p stop_p)

👍 3
noprompt20:12:19

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.

markaddleman20:12:06

that would be pretty cool

noprompt20:12:10

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.

markaddleman20:12:34

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

noprompt20:12:37

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.

noprompt20:12:02

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

noprompt20:12:21

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

noprompt20:12:30

There is m*/top-down-while

markaddleman20:12:58

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

noprompt21:12:02

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 😛

noprompt21:12:11

This is my immortality project. 🙂

markaddleman21:12:01

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
noprompt21:12:18

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.

noprompt21:12:35

That’s a space for anyone and everyone.

markaddleman21:12:01

Yep. That's on my to-do list