Fork me on GitHub
#meander
<
2021-07-29
>
noprompt00:07:31

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.

ribelo00:07:55

I already know something there

ribelo00:07:19

({: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

noprompt00:07:05

(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.

ribelo00:07:30

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

ribelo00:07:59

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

ribelo00:07:21

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

noprompt00:07:27

Indeed. 😛

noprompt00:07:22

Ideally, the substitution namespace would use the IR too.

noprompt00:07:04

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

ribelo00:07:39

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

noprompt00:07:59

Get some sleep! 🙂

noprompt18:07:20

I really enjoyed this one. 🙂

👍 2
ribelo00:07:36

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

markaddleman01:07:38

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.

markaddleman01:07:43

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

noprompt17:07:26

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.

Gary Berger22:07:08

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.

Jimmy Miller22:07:06

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.

Gary Berger22:07:57

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

Jimmy Miller22:07:07

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?

Jimmy Miller22:07:40

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 :)

Gary Berger22:07:48

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.

Jimmy Miller22:07:54

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

👍 8