Fork me on GitHub
#meander
<
2022-09-11
>
Joe12:09:20

Hi! I'm planning to user Meander on the back and front end, with the back end passing the necessary pieces to the front, and then the front end turning those into a valid match expression So the back end would deliver something like this (edn format),

'{:name "test", :schema [:map [:a :int] [:b :int]], 
  :pattern {:a ?a, :b ?b}, 
  :target {:new-a ?a, :new-b ?b}}
And the front end turns that into a function
(fn [data] (e/match data {:a ?a, :b ?b} {:new-a ?a, :new-b ?b}))
Which could then be used. In the back end I can just create that form and evaluate it. But I don't think I can do that from the front. Is there a way I can get this to work? Or would it just be better to have the front end pass the data to the back and have Meander do the xforms there?

noprompt16:09:25

There is an interpreter namespace which can take a quoted form an interpret it. It's cljc so it will work everywhere.

Joe13:09:15

That's perfect, thanks!

Joe07:09:24

@U06MDAPTP, out of interest, I can see in the interpreter namespace there's a finder, searcher, rewriter to match the main ns find, search, rewrite - is there a reason there isn't a matcher to go with the main ns match?

noprompt17:09:06

Its been a while so I can't remember why I didn't add it. If I had to guess its probably because I was being lazy. 🙂

1
noprompt17:09:28

It would basically amount to asking if a pattern is ambiguous.

IAmbiguous
(-ambiguous? [this context] ,,,)