meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
2021-04-07T22:52:23.073Z

Is it possible to remove one key from map with meander?

2021-04-07T22:53:04.073200Z

I know I can rewrite all keys except one, but with a large number of keys this doesn't sound like a good solution

noprompt 2021-04-07T22:55:22.073800Z

(m/rewrite {:a 1 :b 2 :c 3}
  {:a _ & ?rest}
  ?rest)
;; => 
{:b 2, :c 3}
Like this?

noprompt 2021-04-07T22:56:16.074200Z

This almost compiles to (dissoc m :a)

2021-04-07T22:56:43.074400Z

Looks cool, but also doesn't seem to scale well for more operations

noprompt 2021-04-07T22:57:11.074800Z

In what way? Maybe I can help.

2021-04-07T22:57:36.075400Z

I will give you an example, 1s

noprompt 2021-04-07T22:57:45.075600Z

I’ve been staring at something else all day and I want an excuse to look at something else. 🙂

noprompt 2021-04-07T22:58:12.076100Z

Errr, that was redundant but I think you know what I’m saying.

noprompt 2021-04-07T22:59:50.076300Z

1s?

noprompt 2021-04-07T23:00:19.076800Z

OH. YOU MEAN ONE SECOND.

noprompt 2021-04-07T23:00:23.077100Z

😂

2021-04-07T23:00:23.077200Z

(m/rewrite {:a 1 :b 2 :c 3 :d 4 :e 5}
  {:a ?a :b ?b :c ?c :d ?d :as ?m}
  {& ?m
   :a ~(+ ?a ?b)
   :b :swap/dissoc
   :c ~(+ ?c ?d)
   :d :swap/dissoc
   :e :swap/dissoc})
;; => {:a 3, :c 7}

2021-04-07T23:01:02.077400Z

let's say I want to remove the keys from :swap/dissoc

noprompt 2021-04-07T23:04:21.078500Z

By “scale” you mean in terms what you must write?

2021-04-07T23:04:27.078700Z

yes

noprompt 2021-04-07T23:04:38.078900Z

Gotcha

2021-04-07T23:05:21.079500Z

there is a NONE in the specter that can be used to remove keys or other items and overall it useful

noprompt 2021-04-07T23:05:49.080100Z

I guess I would have written it as

(m/rewrite {:a 1 :b 2 :c 3 :d 4 :e 5}
  {:a ?a :b ?b :c ?c :d ?d :e _ & ?m}
  {:a ~(+ ?a ?b)
   :c ~(+ ?c ?d)
   & ?m})
;; => {:a 3, :c 7}
(grabbing the :e) but I see what you mean.

noprompt 2021-04-07T23:07:05.080900Z

Note I’m using & on the left not :as.

noprompt 2021-04-07T23:07:37.081500Z

But maybe there is a reason you’re using :as and not & ?

2021-04-07T23:10:51.082800Z

actually there's no reason, that's the way I used to write, but I'm about to check what's faster and to what code it expands

noprompt 2021-04-07T23:11:32.083300Z

Cleaning up all the nested lets its roughly

(let [R__37813 (let [TARGET__37806 {:a 1, :b 2, :c 3, :d 4, :e 5}
                     T__37811 (.valAt TARGET__37806 :e)
                     T__37810 (.valAt TARGET__37806 :d)
                     T__37809 (.valAt TARGET__37806 :c)
                     T__37808 (.valAt TARGET__37806 :b)
                     T__37807 (.valAt TARGET__37806 :a)
                     ?a T__37807
                     ?b T__37808
                     ?c T__37809
                     ?d T__37810
                     T__37812 (dissoc TARGET__37806 :a :b :c :d :e)
                     ?m T__37812
                     form__28292__auto__ {:a (+ ?a ?b), :c (+ ?c ?d)}]
                 (merge (into {} ?m) form__28292__auto__))]
  (if (meander.match.runtime.epsilon/fail? R__37813) nil R__37813))

noprompt 2021-04-07T23:12:50.084100Z

The into bit there is slightly annoying because the epsilon compiler isn’t smart enough to know ?m is a map.

2021-04-07T23:13:37.085Z

Thanks for the advice, your way is indeed much faster, which after a bit of thought is pretty much obvious.

noprompt 2021-04-07T23:13:38.085100Z

I’ve been thinking that what might satisfy people is to allow map keys to be extensible.

noprompt 2021-04-07T23:14:45.086Z

I know that concision is important to people.

2021-04-07T23:15:33.087Z

it's still awesome

noprompt 2021-04-07T23:16:37.088300Z

I feel a little bad because I’ve been hacking on zeta . If I don’t do it though, I’ll never release it.

2021-04-07T23:17:37.089100Z

specter never clicked in my head, using meander is much easier and more enjoyable

noprompt 2021-04-07T23:18:10.089800Z

Ah, thanks. That kind of support keeps me motivated to work on it. 🙂

2021-04-07T23:18:10.089900Z

I am waiting for the zeta impatiently and with flushed face

noprompt 2021-04-07T23:20:13.091500Z

Well hopefully it doesn’t take much longer. I spent a lot of time experimenting working to come up with something that could address all of the things people have asked for in terms of programmability and explainability.

noprompt 2021-04-07T23:20:53.092500Z

The past month has been mostly on writing a lot of tests and organizing the project.

2021-04-07T23:21:33.093200Z

the nice thing about meander is that it doesn't so much describe individual actions, in which we can get lost, but it describes exactly the structure you have and the one we want, this allows you to figure out what the code is doing in a blink of an eye even after a long time

noprompt 2021-04-07T23:22:06.093800Z

100% the intended result and it makes me happy that I’ve heard this from many people.

noprompt 2021-04-07T23:22:30.094300Z

Hell, I enjoy seeing what people make with it and noticing the same thing!

2021-04-07T23:23:08.095100Z

This is basically the opposite of all the automatic ways, which after some time become completely incomprehensible and we don't know what they really do and what the author had in mind.

noprompt 2021-04-07T23:23:20.095400Z

I think having explanations will be a game changer for the library. 🤞

noprompt 2021-04-07T23:23:39.095600Z

Haha! Yes!

noprompt 2021-04-07T23:23:45.095800Z

That happens to me. 😐

2021-04-07T23:25:12.096100Z

what do you mean by having explanations?

2021-04-07T23:27:57.096300Z

Anyway, I'm keeping my fingers crossed for zeta, but I have to go

2021-04-07T23:28:13.096500Z

thanks again for the tip

noprompt 2021-04-07T23:44:28.097700Z

I mean that it will be possible to get an explanation for why a rewrite failed.

noprompt 2021-04-07T23:47:03.099700Z

This is useful for even small systems but becomes much more valuable as the system grows especially when cata is involved.

2021-04-07T23:50:58.100100Z

cider debugger is an invaluable help, especially when it comes to cata