meander 2021-07-29

Basically what you want is to take a form, parse it, compile it through the match compilation machinery, and then compile that with ir. You’ll then want to save the result of each of those steps.

I already know something there

({:op :bind, :symbol SEQ__21245, :value {:op :eval, :form xs}, :then {:op :branch, :arms ({:op :branch, :arms ({:symbol SEQ__21245__X, :value {:op :eval, :form SEQ__21245}, :op :search, :body {:op :branch, :arms ({:op :check-boolean, :then {:op :branch, :arms ({:op :branch, :arms ({:symbol ?x, :op :lvr-bind, :then {:value ?x, :op :return}, :target {:op :eval, :form SEQ__21245__X}} {:op :fail})} {:op :fail})}, :test {:op :eval, :form (even? SEQ__21245__X)}} {:op :fail})}} {:op :fail})} {:op :fail})}} {:op :fail} {:op :fail})
the most important thing is to get something like this

(let [form '[?x ?y]
      ast (m.match.syntax/parse form env)
      ir (m.match/compile '[TARGET] [{:cols [ast], :rhs true}])
      code ( ir :find env)]
  ,,,)
Something like this.

all :op, are operators, and for each there is a multimethod (defnmethod complie :key...

a little around, but somehow I got to it ; P

any amount of information can be obtained with a finite number of prints

Indeed. 😛

Ideally, the substitution namespace would use the IR too.

But, again, I didn’t really have a solid plan for that because almost all of my attention went into match related code.

I'll hack tomorrow, Now I can barely look at my eyes

Get some sleep! 🙂

I really enjoyed this one. 🙂

👍 1

I remember that you like Mark Grechuta so maybe you will like this one too ; )

picking up on an earlier part of the conversation: meander has become my #1 choice when i need to manipulate a data structure more than just assoc'ing in new data to a map.

comparatively, it's much easier to think about the shape of the data (both before and after) using meander

Very odd.

I think we should probably patch the README to manually recommend a specific version. I know this is experimental software but 0.0.626 is not representing the library well.

Hello all, is there any way to represent a logic variable in a pattern ?foo

{:foo ?foo}
as a string? or is there a way to convert that from a string easily? I want to store the patterns outside the system i.e in a JSON format which will not be marshaled into a symbol automatically.

So we do have interpreter that lets you do dynamic things like that. But I will say that I'm not sure I'd recommend meander as a target like that. Meander is definitely more focused on being a way you write code. It isn't focused on having more dynamic rules. That said, meander is great for writing a little interpreter to do transformations defined in data.

yea thats what I am looking for to translate data in a workflow

Maybe I misunderstood. It sounded like you wanted to store meander patterns as data. Like serialize meander code and then deserialize it and run it. Is that incorrect?

If so, I'd advise against that. I'm betting there are better ways to solve your problem using meander. Happy to help with the more concrete problem if that's the case :)

yea well thats what I am looking for, a simple declarative approach to change the shape of input data such that I pass the input + pattern from outside the system to a function that does the translation.

So with meander you have two options, use the meander interpreter (still a bit experimental). Or use meander to write an interpreter for your patterns that is specific to your app. That's my recommendation. I wrote a blog post that is kind of like that, writing a meander interpreter and then compiler all using meander. https://jimmyhmiller.github.io/building-meander-in-meander

👍 3