Fork me on GitHub
#meander
<
2021-07-28
>
Geoffrey Gaillard15:07:05

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?

noprompt18:07:01

@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 Gaillard19:07:08

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

noprompt18:07:45

0.0.626 has some bugs and I would recommend using 0.0.602

schmee19:07:48

really nice improvement between the two versions! 😄

schmee19:07:00

does Meander have a changelog somewhere?

noprompt19:07:23

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

noprompt19:07:39

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

noprompt20:07:04

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

noprompt20:07:39

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

noprompt20:07:58

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

noprompt20:07:20

Aaaaaand I would totally merge a patch for that! 😉

ribelo22:07:42

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

😆 3
ribelo22:07:54

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

noprompt22:07:00

“niche of niche” 😛

noprompt22:07:29

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

ribelo22:07:13

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.

ribelo22:07:39

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

noprompt22:07:41

Thats enough for me! 🙂

noprompt22:07:40

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

noprompt22:07:52

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

ribelo22:07:58

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

noprompt22:07:47

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

noprompt22:07:21

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

ribelo22:07:22

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

ribelo22:07:49

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.

noprompt22:07:50

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

noprompt22:07:48

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

ribelo22:07:30

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

noprompt22:07:35

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

noprompt22:07:48

Is it good?

noprompt22:07:58

Ah, thats great.

noprompt22:07:04

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

ribelo22:07:22

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

noprompt22:07:07

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

ribelo22:07:44

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

ribelo22:07:06

which is not easy at all

noprompt22:07:28

Yeah. There are definitely some rough edges in cljs.

ribelo23:07:44

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

noprompt23:07:02

Not a stupid question.

ribelo23:07:02

I'm talking about search

noprompt23:07:02

It mostly has to do with scope.

noprompt23:07:39

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.

noprompt23:07:53

The latter, however, will totally work with transducers.

ribelo23:07:55

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

noprompt23:07:59

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.

noprompt23:07:11

Right now, epsilon is not so great for that.

noprompt23:07:42

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

ribelo23:07:49

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

ribelo23:07:07

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

noprompt23:07:13

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

schmee23:07:39

haha, this turned into quite the conversation 😄

schmee23:07:25

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

schmee23:07:41

it’s an incredible piece of work 😄

ribelo23:07:49

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

ribelo23:07:07

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

noprompt23:07:20

Ugh, its sadly an “art”.

noprompt23:07:28

I may have some stuff to help.