meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
dominicm 2019-12-04T09:19:43.316300Z

for parsing a defn with meander, there's the case of the optional docstring. Is it possible to do some kind of (m/? (m/pred string? ?docstring)) that when rewritten will take "no space" if it couldn't be bound to anything?

noprompt 2019-12-04T18:02:53.316700Z

@dominicm Not yet!

dominicm 2019-12-04T18:06:12.317500Z

That's okay. I just copy-pasted the rule I had :)

dominicm 2019-12-04T18:06:25.317600Z

I realized I probably would want slightly special handling for the docstring anyway.

dominicm 2019-12-04T18:06:57.317700Z

I'm using meander as part of my code formatter. I feel like such a pedant right now 😁. "No more docstrings on the same line as the arglists for you!" "Banish that vertical alignment" (I've decided my code formatter is evil, rather than positive. Just a personality thing.)

noprompt 2019-12-04T18:08:56.318500Z

That sounds fantastic.

noprompt 2019-12-04T18:09:00.318800Z

I’d really like to see what you cook up.

noprompt 2019-12-04T18:39:59.321700Z

FWIW, For things like defn I tend to write separate rules for each of the cases. In some cases I might use m/with if its not too complex but I tend to stick with multiple rules because I find it easier to grok.

dominicm 2019-12-04T19:38:01.323Z

@noprompt have you started experimenting? I'd be curious to know what you are using in combination.

noprompt 2019-12-04T20:33:12.323300Z

@dominicm On what?

noprompt 2019-12-04T20:33:32.323900Z

Also, a gift! 👉 https://github.com/noprompt/meander/blob/epsilon/doc/defsyntax.md

🎁 1
❤️ 1
noprompt 2019-12-04T20:34:51.325400Z

I hope that article helps explain defsyntax a bit better. It doesn’t go into implementation details or anything like that but I think it does equip folks with enough information to be “dangerous”.

noprompt 2019-12-04T20:34:52.325600Z

🙂

dominicm 2019-12-04T20:50:16.325700Z

What are you using meander for so far. I assume you're using it with other libraries. What libraries?

noprompt 2019-12-04T21:08:31.326100Z

Yeah. I’m mostly messing around with experimental interpreter/compiler stuff. I have a part of a syntax search and replace tool which I need to make a thing. We’ve made some good use of it at work to do basic/complex stuff. Basic being match , complex being search to pull out many things of interest on a single data structure where a maze of mapcat would pretty much make it unclear what the hell is going on. 🙂

dominicm 2019-12-04T21:41:02.326300Z

Clojure interpreter? Curious what you're using for whitespace for search replace.

noprompt 2019-12-04T21:45:50.326500Z

So my search and replace solution is kind of janky insofar as it doesn’t account for whitespace but it should. Essentially its pattern matching and pretty prettying the substitution. The pretty printing is using stock pprint but what I’d rather do is have rewrite rules turning sexprs into fipp instructions and just have fipp do the work of printing.

noprompt 2019-12-04T21:46:45.326700Z

I’ve got a small step Clojure interpreter I’m working on and off on but its a mountain of work deriving it.

noprompt 2019-12-04T21:48:02.326900Z

I’ve also written an interpreter for a language I’ve code named “daft” which is basically a mash up of meander and a specific pattern of core.async use.

noprompt 2019-12-04T21:49:23.327100Z

These kinds of projects really motivated me to make Meander because often I want to experiment with new ideas but the drudgery of doing it with vanilla Clojure is, frankly, crazy making.

noprompt 2019-12-04T21:49:56.327300Z

Have you given any thought to using fipp for the work you’re doing?

dominicm 2019-12-04T22:01:04.327500Z

Fipp isn't really what I'm after I think. My current formatter is an unformatter really. It undoes patterns which are hard to maintain (vertical whitespace), or which violate my personal sensibilities on consistency in a codebase (different namespace aliases). I'm intentionally avoiding things like 2 vs 1 space indents because it's a battle of the editor and context. I suppose you can consider it the set of things which could easily be done manually if you were thinking about it. Eg a newline before the arglist in defn. I'm otherwise trying to preserve everything about the code.

dominicm 2019-12-04T22:02:14.327800Z

Make sure to use a reader which preserves whitespace. You'll want to make sure you hold onto comments. That's the big problem with pprint approaches :)

dominicm 2019-12-04T22:04:10.328Z

That's good. Dangerous capabilities are important.