meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
noprompt 2019-10-31T04:57:19.161200Z

I’m very close to having cata working on the right side. 🙂

noprompt 2019-10-31T05:43:13.161500Z

Oh man this is cool.

noprompt 2019-10-31T05:43:15.161700Z

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

2019-10-31T12:17:21.161900Z

That's awesome!

eraserhd 2019-10-31T15:06:42.163300Z

This fails to compiled: (m/search nil (m/not {:taskexec/program {:program/uuid (m/some _)}}) :ok)

eraserhd 2019-10-31T15:06:57.163700Z

Unable to resolve symbol: save__351922 in this context

eraserhd 2019-10-31T15:07:28.164100Z

Replacing :taskexec/program with _ works.

jimmy 2019-10-31T15:53:24.165300Z

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.

noprompt 2019-10-31T18:11:32.167Z

Two awful things: recursion and negation. 🥨

noprompt 2019-10-31T18:14:37.167900Z

One quick fix might be to use (pred some?) as the definition.

noprompt 2019-10-31T18:15:22.168700Z

But nested negations shouldn’t break and that needs repair.

noprompt 2019-10-31T18:25:53.168900Z

(m/search nil (m/not (m/some _)) :ok)
;; => (:ok)
(m/search nil (m/not {:taskexec/program {:program/uuid (m/some _)}}) :ok)
;; => (:ok)

noprompt 2019-10-31T18:26:27.169600Z

So, yeah, just changing the definition of some gets it out of the mud but the fact is the problem is still there.

eraserhd 2019-10-31T18:26:52.170300Z

yeah, (m/pred some? _) is working for me.

noprompt 2019-10-31T18:27:58.171Z

Alright, so the problem is definitely with nested negation.

noprompt 2019-10-31T18:28:25.171600Z

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.

jimmy 2019-10-31T18:29:32.172100Z

When I was looking at the IR, things look correct to me even after rewrite, but the codegen was lacking the save node.

noprompt 2019-10-31T18:30:43.172400Z

So probably in the matrix?

noprompt 2019-10-31T18:31:36.172800Z

Is it affecting match too?

noprompt 2019-10-31T18:31:51.173200Z

I’m AFK for just a bit.

jimmy 2019-10-31T18:34:34.175Z

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.

jimmy 2019-10-31T18:37:27.175700Z

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.

noprompt 2019-10-31T19:00:19.176Z

Hmm…

noprompt 2019-10-31T19:11:43.176500Z

That’s the bug.

noprompt 2019-10-31T19:18:30.177900Z

[meander/epsilon "0.0.314"]

👍 1
noprompt 2019-10-31T19:18:40.178200Z

☝️ And there’s the patch.

jimmy 2019-10-31T19:24:33.178700Z

Yeah when I saw that ir I felt it had to be something simple like that.

noprompt 2019-10-31T19:39:30.180400Z

Variadic arguments amirite. 🙃

noprompt 2019-10-31T19:39:54.181100Z

Unary = is like a feature and a bug. 😂

noprompt 2019-10-31T19:40:41.181500Z

Which means it’s broken. 🤪

noprompt 2019-10-31T22:11:21.182900Z

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.