I’m very close to having cata
working on the right side. 🙂
Oh man this is cool.
(let [x '(branch
(leaf (s (s 0)))
(leaf (s 0)))]
(m/rewrite x
(leaf 0)
(leaf 0)
(leaf (s ?A))
(branch (leaf 0) (m/cata (leaf ?A)))
(branch ?A ?B)
(branch (m/cata ?A) (m/cata ?B))))
;; =>
(branch (branch (leaf 0)
(branch (leaf 0)
(leaf 0)))
(branch (leaf 0)
(leaf 0)))
That's awesome!
This fails to compiled: (m/search nil (m/not {:taskexec/program {:program/uuid (m/some _)}}) :ok)
Unable to resolve symbol: save__351922 in this context
Replacing :taskexec/program
with _
works.
Not sure why this is happening, but just to give a more minimal reproducing case.
(m/search nil (m/not (m/some _)) :ok)
Seems to be the not and some nested. I might have time later to today to look into it if someone else doesn’t beat me to it.Two awful things: recursion and negation. 🥨
One quick fix might be to use (pred some?)
as the definition.
But nested negations shouldn’t break and that needs repair.
(m/search nil (m/not (m/some _)) :ok)
;; => (:ok)
(m/search nil (m/not {:taskexec/program {:program/uuid (m/some _)}}) :ok)
;; => (:ok)
So, yeah, just changing the definition of some
gets it out of the mud but the fact is the problem is still there.
yeah, (m/pred some? _)
is working for me.
Alright, so the problem is definitely with nested negation.
I suppose the “right” thing to do would be to just patch that rather than make a patch that doesn’t actually solve the underlying problem.
When I was looking at the IR, things look correct to me even after rewrite, but the codegen was lacking the save node.
So probably in the matrix?
Is it affecting match too?
I’m AFK for just a bit.
No I mean it seemed to get all the way to the end of my analyze little function but for some reason the save node didn't get a letfn. I could be wrong though. On my phone right now.
IR:
{:symbol target__18102,
:value {:op :eval, :form nil},
:op :bind,
:then
{:op :branch,
:arms
({:body-1
{:op :branch,
:arms
({:body-1
{:op :branch,
:arms
({:value {:op :eval, :form nil},
:op :check-lit,
:then {:op :load, :id save__18104},
:target {:op :eval, :form target__18102}}
{:op :fail})},
:op :save,
:id save__18104,
:body-2 {:op :load, :id save__18103}}
{:op :fail})},
:op :save,
:id save__18103,
:body-2 {:value :ok, :op :return}}
{:op :fail})}}
Code:
(clojure.core/let
[target__18102 nil]
(clojure.core/letfn
[(save__18103
[]
((clojure.core/fn
[]
(throw
(clojure.core/ex-info "non exhaustive pattern match")))))
(f__18105 [] (clojure.core/list :ok))]
(clojure.core/case target__18102 (nil) (save__18104) (f__18105))))
No save__18014
letfn.Hmm…
https://github.com/noprompt/meander/blob/epsilon/src/meander/match/ir/epsilon.cljc#L1538
That’s the bug.
[meander/epsilon "0.0.314"]
☝️ And there’s the patch.
Yeah when I saw that ir I felt it had to be something simple like that.
Variadic arguments amirite. 🙃
Unary = is like a feature and a bug. 😂
Which means it’s broken. 🤪
I pushed up the initial work on substitution cata. I’ve got a few more things to clean up and install before I can make a release.