meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
jimmy 2021-06-14T16:16:28.018Z

Really interesting pattern you have there. I personally, haven't had that use case, so haven't really thought about it. Does it work with multiple of them nested? Might have to play around with it

noprompt 2021-06-15T22:56:42.046600Z

I want to keep this alive too. The conversation about editing is important.

👍 1
markaddleman 2021-06-15T23:36:08.047Z

I will try to write up some code examples this weekend

markaddleman 2021-06-19T14:52:43.052800Z

Picking this back up

markaddleman 2021-06-19T14:54:32.053Z

I played around with a new pattern match operator that I call edit. I tried getting it to work the way I describe above but I ran into a problem with recursion. I just couldn't find an intuitive way to express how to recurse when then target rule is different than the matching rule

markaddleman 2021-06-19T14:55:33.053200Z

I'm back to believing that the edit use case is best served something like the within syntax. see https://clojurians.slack.com/archives/CFFTD7R6Z/p1623543354015700

markaddleman 2021-06-19T14:56:08.053500Z

The within syntax that I wrote doesn't really follow the spirit of meander so I'm going to play around with a better cultural fit today.

markaddleman 2021-06-19T15:00:22.053700Z

The problem with something like within is that it needs to introduce multiple matching variables each of whose names must match in the match-syntax phase and the subst-syntax phase. I think it would be safer if the pattern matching operator (`rewrite` in this case) provided some context that could be shared between the two macro expansion phases

markaddleman 2021-06-14T17:09:09.018100Z

I wrote it for a very particular use case - "editing" XML

markaddleman 2021-06-14T17:09:44.018300Z

I believe I have one nested use case and I haven't seen a problem. I'll look more deeply into it

markaddleman 2021-06-14T17:11:16.018500Z

I got to thinking that the "edit" use case might deserve a DSL of its own. The DSL would be similar to m/rewrite but every "rule" would need to specify three things:

markaddleman 2021-06-14T17:14:37.018700Z

1. a matching rule - just like the current rewrite LHS. the matching rule is used to capture values to be used later 2. the new value rule. this is similar to rewrite's RHS but a new value rule would only return a value that would be used to replace an existing node in the tree 3. a targeting rule. this is a rule that works similarly to matching rule but is used to locate the position(s) of the new value

noprompt 2021-06-14T18:54:48.019400Z

@markaddleman That looks interesting. You didn’t come across as a snarky either. 🙂

🙏 1
noprompt 2021-06-14T18:56:32.020100Z

I’ve done this before too but I confess that I hadn’t thought about doing it this way.

noprompt 2021-06-14T18:57:56.021700Z

This actually makes me think that, among other things, we should be able to use & more than once in sequential types of patterns.

(& ?before <pattern> ,,, & ?after)

markaddleman 2021-06-14T18:59:49.022Z

that would be convenient

markaddleman 2021-06-14T19:00:06.022700Z

What do you think of the edit DSL idea? https://clojurians.slack.com/archives/CFFTD7R6Z/p1623690549018100?thread_ts=1623687388.018000&cid=CFFTD7R6Z

noprompt 2021-06-14T19:06:25.023900Z

I think it makes sense and would be able to contribute more thoughts provided an example/sketch.

markaddleman 2021-06-14T19:07:51.024Z

Oh, one more difference from rewrite: If no edit rules match, return the original form

markaddleman 2021-06-14T19:08:21.024600Z

Cool.

markaddleman 2021-06-14T19:09:03.025400Z

I could play around with some example syntax and post here

noprompt 2021-06-14T19:20:03.027Z

Its certainly welcome. 🙂