meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
timothypratley 2020-05-02T00:03:50.181200Z

do you mean automatically try to match metadata? I guess there is an existing feature for sets which needs to be considered: ^{& ?rest-set} #{} but that seems like a pretty low collision chance! 🙂

timothypratley 2020-05-02T00:06:21.181500Z

Argument for: Seems convenient, Argument against: Metadata is not considered in equality (is that important??? I don’t think so)

noprompt 2020-05-02T03:32:06.181700Z

See also: https://github.com/noprompt/meander/issues/122#issuecomment-620983655

đź‘Ť 1
pbaille 2020-05-02T06:45:52.187Z

Hello! I'm playing with meander and am really impressed by it. I was wondering what would be the meander way to parse a regular clojure fn or defn form ? (i'm struggling a bit in order to express elements that could be there or not (like the name of the lambda or the metadata map in the `defn for instance). thank you in advance.

jimmy 2020-05-04T15:53:50.187300Z

Sorry for the late reply. I will hopefully be able to answer this thoroughly today. It is actually something that comes up quite often so, I plan on adding some examples to the cookbook. Optionality is a little difficult just because it is context sensitive. The easiest (but often times not scalable) answer is to make multiple patterns that match with or with out it. Like I said, I should have an example later today.

timothypratley 2020-05-04T19:44:08.192300Z

@pbaille Here is one way: https://github.com/timothypratley/justice/blob/master/src/justice/defn.cljc

timothypratley 2020-05-04T19:44:49.192600Z

FWIW If you compare it with the “spec driven approach” linked in the comment I think Meander is way more expressive 🙂

timothypratley 2020-05-04T19:45:37.192800Z

note that the way I emulated “optional” was to use a memory variable constrained to contain 1 or 0 elements

timothypratley 2020-05-04T19:45:54.193Z

I wish Meander had a built in operator for optional (hint hint @noprompt)

noprompt 2020-05-04T19:48:27.193200Z

@timothypratley The memory variable trick works too. I didn’t use it in the example. 🙂

jimmy 2020-05-04T19:48:53.193600Z

I tried to hack on in one time. But the compiler depends on the length of a pattern quite often to be able to do things intelligently. I found myself running into trouble because of that.

timothypratley 2020-05-04T19:52:08.193800Z

Also as a side topic; you can use tools analyzer to parse/emit normalized versions then match with meander to remove most optionality (happy to share examples on that too if interesting).

đź‘Ť 1