This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-28
Channels
- # announcements (11)
- # aws (2)
- # babashka (35)
- # beginners (173)
- # calva (3)
- # chlorine-clover (2)
- # cider (17)
- # clara (2)
- # clj-kondo (28)
- # cljs-dev (11)
- # cljsrn (53)
- # clojure (178)
- # clojure-argentina (1)
- # clojure-europe (12)
- # clojure-germany (5)
- # clojure-italy (4)
- # clojure-nl (5)
- # clojure-spec (25)
- # clojure-uk (88)
- # clojurescript (109)
- # conjure (34)
- # cursive (2)
- # data-science (35)
- # datomic (15)
- # emacs (6)
- # events (1)
- # fulcro (28)
- # graphql (15)
- # helix (21)
- # hoplon (7)
- # jobs (4)
- # jobs-discuss (1)
- # joker (15)
- # lambdaisland (1)
- # lein-figwheel (4)
- # local-first-clojure (1)
- # malli (8)
- # meander (17)
- # off-topic (33)
- # parinfer (2)
- # rdf (16)
- # re-frame (3)
- # reagent (21)
- # reitit (14)
- # remote-jobs (5)
- # ring (8)
- # rum (1)
- # shadow-cljs (184)
- # sql (2)
- # testing (1)
- # tools-deps (23)
Hi! I am not understanding why something like this works
(ms/rewrite
(me/with [%e-entidade (me/or (= e (me/pred symbol? ?e))
(= (me/pred symbol? ?e) e))
%a-atributo (me/or (= a (me/pred keyword? ?a))
(= (me/pred keyword? ?a) a))
%v-valor (me/or (= v (me/pred symbol? ?v))
(= (me/pred symbol? ?v) v))
%v-args (me/or (me/pred symbol? ?v))
%v-teste-unario ((me/pred function? !funcao-unaria) !param-function-unaria)
%operador-binario (me/pred #{'< '> '<= '>= 'not=} !funcao-binaria)
%v-teste-binario (%operador-binario %v-args !param-function-binaria)
%v-teste-funcao (me/or %v-teste-unario %v-teste-binario)
%v-expression (me/or %v-valor %v-teste-unario %v-teste-binario)]
[%e-entidade %a-atributo %v-valor . %v-teste-funcao ..1]) :ok)
but if I add any other params in the the (me/or of %v-args, eg,
%v-args (me/or (me/pred symbol? ?v) a-symbol)
I get an Unable to resolve symbol: ?v in this context
What am I missing?
Thanks in advance!@nlessa Definitely looks like a bug. Will try to find some time today to dig into it.
I am a little confused as to what you are trying to accomplish though. Do you have an example of the data your are matching on?
Those = signs are not going to be doing what I think you want them to do.
So while I might be able to find the bug, I want to make sure you can accomplish your task as well.
Thanks, @jimmy! The symbols = appears in the grammar that is being rewrited. It's been working fine, only with this little problem with the me/or. The use case I am working is a transformation from rules expressed in Clara Rules to datalog clauses. Meander worked very well! I faced only this and another strange problem (but with workaround) . I will post later here the other problem I found.
Okay, cool. Just wanted to make sure that the =
signs were meant to be literals.
Also great to hear that it is working for you. Interesting to see a transformation from clara to datalog. Hopefully we can help fix those remaining issues.
Okay so the fact that you get the error you do is a bug. But for %v-args (me/or (me/pred symbol? ?v))
if you want something else in the or
you need to make sure it has ?v
in it.
If you add a pattern that includes ?v
there you should be fine. We are clearly failing to detect that problem correctly though and so we generate bad code.
@noprompt Just fyi. Looks like we consider ?v
bound already because of %v-valor
and so argument-lvrs is empty. https://github.com/noprompt/meander/blob/b2a6ab1135f3bf3be3abf2f113930c4ffec71f04/src/meander/match/check/epsilon.cljc#L154-L187
@jimmy Thanks for taking a look. Do you have a patch in mind or did you want me to take it from here?
(I’ve encountered it once in the last couple months but didn’t have a chance to properly look into it.)
I haven't had a chance to think of a fix. Need to familiarize myself with that code. Just wanted to dump the little bit I found here.