meander

Geoffrey Gaillard 2021-07-28T15:17:05.192800Z

Hello! I’m trying to rewrite an infix pattern into prefix, like:

'[1 2 3 4 ! 5 6 7] => '[1 2 3 (! 4 5) 6 7]
I’m using rewrite but I can’t figure out the rule. Have I missed a doc page?

noprompt 2021-07-28T18:45:01.193500Z

@ggaillard Here are a couple approaches.

;; Before 0.0.626
(let [xs [1 2 3 4 '! 5 6 7 9]]
  (m/rewrite xs
    [!head ... ?x '! ?y . !tail ...]
    [!head ... ('! ?x ?y) . !tail ...]))
;; =>
[1 2 3 (! 4 5) 6 7 9]

;; 0.0.626 and later
(let [xs [1 2 3 4 '! 5 6 7 9]]
  (m/rewrite xs
    [& ?head ?x '! ?y & ?tail]
    [& ?head ('! ?x ?y) & ?tail]))
;; =>
[1 2 3 (! 4 5) 6 7 9]

Geoffrey Gaillard 2021-07-28T19:00:08.194500Z

Cool! I'll try this. Thank you very much!

noprompt 2021-07-28T18:45:45.194400Z

0.0.626 has some bugs and I would recommend using 0.0.602

schmee 2021-07-28T19:24:48.195Z

really nice improvement between the two versions! 😄

schmee 2021-07-28T19:25:00.195300Z

does Meander have a changelog somewhere?

noprompt 2021-07-28T19:58:23.195700Z

It does not. It should. There are only so many things I can keep up with. 😛

noprompt 2021-07-28T19:59:39.197Z

Does anyone know of a strategy for automatically computing a changelog?

noprompt 2021-07-28T20:00:04.197400Z

One thing we could do is make that a part of the release building process.

noprompt 2021-07-28T20:00:39.198100Z

Perhaps we could look at the commit history between the last tagged release, parse it, and make a changelog?

noprompt 2021-07-28T20:00:58.198400Z

It wouldn’t be perfect but it would at least be something!

noprompt 2021-07-28T20:01:20.198900Z

Aaaaaand I would totally merge a patch for that! 😉

2021-07-28T22:24:42.199100Z

IMHO changelog is not needed. Meander can safely be considered a niche of clojure niche library.

😆 1
2021-07-28T22:26:54.199600Z

The few people who use it are certainly smart enough to be able to figure out the changes from the commit history 🙃

noprompt 2021-07-28T22:40:46.200Z

LOL

noprompt 2021-07-28T22:41:00.200300Z

“niche of niche” 😛

noprompt 2021-07-28T22:41:29.201Z

Jimmy recently cast it as “avant-garde” which I thought was both high-praise and certain doom. 🙂

2021-07-28T22:43:13.201200Z

But here, there's no fooling around, and you can be happy about it. It's our, or at least mine, secret super weapon and super toy.

2021-07-28T22:48:39.202100Z

You don't have many followers in the meandering church, but anyone who uses a meander will certainly appreciate it.

noprompt 2021-07-28T22:48:41.202200Z

Thats enough for me! 🙂

noprompt 2021-07-28T22:49:40.202700Z

I mean, FWIW, the term rewriting space is, well, pretty sparse.

noprompt 2021-07-28T22:49:52.203Z

In terms of population and people who “get it”.

2021-07-28T22:50:58.203300Z

If you wanted to be the idol of the crowds, you should have written terminal spinners in javascript, or something equally groundbreaking.

noprompt 2021-07-28T22:51:24.204Z

One day.

noprompt 2021-07-28T22:51:47.204400Z

I’ve been thinking that its probably time for me to just make an actual language out of this thing.

noprompt 2021-07-28T22:52:21.205100Z

Primarily, I want to build something that is only focused on manipulating data between two pipes.

2021-07-28T22:52:22.205200Z

regarding term rerwriting, I suspect I don't get it but I use it anyway. 🙃

2021-07-28T22:53:49.206600Z

meander is already like a programming language, and writing macros that use meander to write code for meander is an inception that bends the mind.

noprompt 2021-07-28T22:53:50.206700Z

Anyone thats applied an identity in algebra/trigonometry etc understands term rewriting.

noprompt 2021-07-28T22:53:55.206900Z

LOL

noprompt 2021-07-28T22:54:48.207600Z

It is a language, true. But its in Clojure alongside hundreds of other languages.

2021-07-28T22:55:30.208200Z

Of the things I've noticed that sell meander well is the size of the buildsize for CLJS

noprompt 2021-07-28T22:55:35.208400Z

I’d like to be in the same space as, say, like jq or comby.

noprompt 2021-07-28T22:55:48.208600Z

Is it good?

2021-07-28T22:55:52.208900Z

yes

noprompt 2021-07-28T22:55:58.209100Z

Ah, thats great.

noprompt 2021-07-28T22:56:04.209300Z

I know for a while we had some trouble with that.

2021-07-28T22:56:22.209700Z

meander adds almost nothing of its own, it is after all a macro

noprompt 2021-07-28T22:57:07.210600Z

And on top of that it tries to generate the best code it can considering its shoot-from-the-hip design. 😛

2021-07-28T22:58:44.211900Z

for more difficult things, I'm almost sure that the resulting code will be smaller than normal, as cljs has a lot of kinks and things to avoid

2021-07-28T22:59:06.212200Z

which is not easy at all

noprompt 2021-07-28T22:59:28.212700Z

Yeah. There are definitely some rough edges in cljs.

2021-07-28T23:00:44.213100Z

i have a stupid question, why meander use lazy collections and not for example transducers?

noprompt 2021-07-28T23:08:02.213700Z

Not a stupid question.

2021-07-28T23:08:02.213800Z

I'm talking about search

noprompt 2021-07-28T23:09:02.214700Z

It mostly has to do with scope.

noprompt 2021-07-28T23:10:39.216200Z

Meander compiles things like (let [?x TARGET] ,,,) instead of (assoc state '?x TARGET) and, it could be my lack of imagination, but the former is hard to shoe into a transducer approach.

noprompt 2021-07-28T23:10:53.216600Z

The latter, however, will totally work with transducers.

2021-07-28T23:13:55.217Z

As I am just checking search, changing to into [] is ~2x faster

2021-07-28T23:15:43.217300Z

http://ix.io/3um4

noprompt 2021-07-28T23:24:59.218800Z

OK. Thats good information. Honestly, I think this project needs to be more accessible and problems like these should be easier to resolve with some help.

noprompt 2021-07-28T23:25:11.219200Z

Right now, epsilon is not so great for that.

noprompt 2021-07-28T23:25:42.219800Z

The approach I’ve tried with zeta works really well for interpretation but has proven to be too slow for macro compilation.

2021-07-28T23:27:49.221300Z

We'll see soon if it's too difficult. If I can handle redoing it through metadata then that means anyone could

2021-07-28T23:28:07.221700Z

and by the way, I'll find out how it works underneath

noprompt 2021-07-28T23:28:13.221900Z

I think its probably the best way to sneak something from the future in.

schmee 2021-07-28T23:32:39.222500Z

haha, this turned into quite the conversation 😄

schmee 2021-07-28T23:33:25.223400Z

I agree that Meander is secret sauce, I’ve used it for some things where I just end up staring at the solution in awe cause it’s so clear and concise

schmee 2021-07-28T23:33:41.223800Z

it’s an incredible piece of work 😄

noprompt 2021-07-28T23:34:53.224100Z

Awesome.

2021-07-28T23:42:49.224700Z

@noprompt, is there any way to debug meander? To understand what is going on and refer to the expanded code somehow?

2021-07-28T23:44:07.224900Z

I think I know, but I don't know at what point I can print out a sequence with operators that will later be compiled into code

noprompt 2021-07-28T23:59:20.225500Z

Ugh, its sadly an “art”.

noprompt 2021-07-28T23:59:28.225800Z

I may have some stuff to help.