This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-29
Channels
- # babashka (64)
- # beginners (60)
- # calva (10)
- # circleci (3)
- # clj-kondo (62)
- # cljdoc (6)
- # clojars (2)
- # clojure (152)
- # clojure-europe (19)
- # clojure-nl (3)
- # clojure-uk (18)
- # clojurescript (50)
- # clojureverse-ops (12)
- # core-async (21)
- # cursive (6)
- # data-science (1)
- # datomic (17)
- # events (14)
- # fulcro (64)
- # graalvm (20)
- # graphql (5)
- # honeysql (14)
- # jackdaw (3)
- # jobs (1)
- # jobs-discuss (22)
- # kaocha (2)
- # lsp (9)
- # luminus (8)
- # malli (30)
- # meander (31)
- # other-languages (1)
- # polylith (8)
- # re-frame (15)
- # shadow-cljs (85)
- # specter (2)
- # sql (11)
- # tools-deps (56)
- # vim (39)
- # vscode (7)
- # xtdb (16)
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.
({: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...
But, again, I didn’t really have a solid plan for that because almost all of my attention went into match related code.
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
@noprompt Unfortunately 0.0.626 breaks one more thing https://github.com/noprompt/meander/issues/195
Hmm… That is strange. There are tests for that. Here’s one: https://github.com/noprompt/meander/blob/epsilon/test/meander/epsilon_test.cljc#L2543
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