meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
noprompt 2019-12-16T19:48:40.010400Z

@dominicm Whatever you’re working on can I conveniently do something like

(m/rewrite form
  (t/deftest _ & (m/gather (t/testing & _ :as !test-forms)))
  (do . (t/deftest ~(gensym) !test-forms) ...))

noprompt 2019-12-16T19:49:06.011Z

I haven’t gotten around to it yet but I really wanna be able to do something like this from my editor.

noprompt 2019-12-16T19:49:30.011600Z

Right now I have to do something like like (def form ,,,) and then eval the rewrite rule in my buffer, copy/paste.

eraserhd 2019-12-16T21:09:22.011800Z

So, this shouldn't happen, right? https://gist.github.com/eraserhd/6869f014414ab605efeb4a47410ca214

jimmy 2019-12-17T15:04:52.020600Z

Once this patch lands I will reason more about this. Right now that bug is throwing me off. But yes I think you are probably right that there will be a case of P ^ ~P. But that is because we are searching. We are trying to find some subset of the map that will satisfy both of theses predicates. So we can search in the hash and find a way of satisfying both. Maps don't do the repeat operator. The behavior you want is what we would have in a hash-map operator. It would do all the things you are talking about.

jimmy 2019-12-18T02:07:41.020800Z

So yes, you can indeed get p and not p. And I do think that makes sense.

(let [prod-snapshot 
      {1 2
       2 1
       3 5
       5 3}]
  (m/search prod-snapshot
    (m/and {_ ?p} (m/not {_ ?p})) 
    ?p))
When we are searching on maps, we are searching for key value pair combinations that match our pattern. We are not saying that the whole map needs to meet our requirements. For example.
(let [prod-snapshot 
      {1 2
       2 1
       3 5
       5 3}]
  (m/search prod-snapshot
    {?p ?q
     ?q ?p} 
    [?p ?q]))

;; =>
([5 3] [2 1] [1 2] [3 5])

jimmy 2019-12-18T02:12:17.021100Z

In my view, this makes sense. Currently to get the behavior you are looking for you’d need to do something like this.

(let [prod-snapshot 
      {1 2
       2 1
       3 5
       5 3}]
  (m/search prod-snapshot
    {?p _
     & (m/seqable [_ (m/not ?p)] ...)} 
    ?p))
This says that none of the elements have ?p in the value position. The difference here is really that some vs none. With (m/not {_ ?p}) you are saying is there any key value pair that has a value that is not ?p. We are not asserting anything about the whole entire map, just some part of it. We should add the hash-map operator to allow you to talk about the whole thing. I will try to find some time over the christmas break to do that and make sure tests are working properly. On master the original problem is fixed, but it has uncovered more issues we have with negation that might take a bit more work to fix. Will hopefully find some time to file bug reports for those.

eraserhd 2019-12-20T15:46:26.001Z

I'm completely unable to model this. Can I ask some questions?

eraserhd 2019-12-20T15:46:39.001200Z

In (m/not {?k ?v}), is ?k supposed to be bound?

eraserhd 2019-12-20T15:46:45.001400Z

When searching.

eraserhd 2019-12-20T15:48:55.001600Z

2. The conclusion from above is that whether {?k ?v} matches some map is irrelevant as to whether (m/not {?k ?v})

eraserhd 2019-12-20T15:49:03.001800Z

matches the map?

eraserhd 2019-12-20T15:49:24.002Z

(That's how we get (P and not P).

jimmy 2019-12-20T15:49:41.002200Z

Sadly right now no. I'm not sure if we could always do that even if we did support it

eraserhd 2019-12-20T15:49:58.002400Z

That's on binding ?k?

jimmy 2019-12-20T15:50:42.002600Z

Yes. Unless it is already bound. It won't be

eraserhd 2019-12-20T15:51:02.002800Z

But it should, you are saying?

jimmy 2019-12-20T15:51:22.003Z

I'm unsure. If we can do it yes. But it isn't currently supported.

eraserhd 2019-12-20T15:51:33.003200Z

Ok.

jimmy 2019-12-20T15:51:41.003400Z

The code gen does not try to bind it.

eraserhd 2019-12-20T15:51:59.003600Z

Ok, that helps me understand this a little bit better.

eraserhd 2019-12-20T15:54:35.003800Z

So should (m/search [1 2] (m/not [_ ... 2 . _ ...]) :ok) return (:ok)?

eraserhd 2019-12-20T15:55:29.004Z

Oh, better example:

eraserhd 2019-12-20T15:55:55.004200Z

should (m/search #{1 2} (m/not #{2}) :ok) return (:ok).

jimmy 2019-12-20T16:10:43.004400Z

Yes

jimmy 2019-12-20T16:11:17.004600Z

If it doesn't, that has been fixed on master and we need to release a new version.

eraserhd 2019-12-20T16:12:25.004800Z

Back to the previous example with the ellipsis then... that should return (:ok)?

eraserhd 2019-12-20T16:13:05.005Z

I think I'm forming a kind of model here, maybe?

jimmy 2019-12-20T16:13:13.005200Z

I'm grabbing lunch with a friend right now so I won't be able to respond right now. I'm also traveling this whole weekend. But once I get some free time I plan on looking into how not is working with search. Write a bunch of tests and see what things I feel are right and wrong.

jimmy 2019-12-20T16:13:29.005400Z

Which example?

eraserhd 2019-12-20T16:14:00.005600Z

The (m/search [1 2] (m/not [_ ... 2 . _ ...]) :ok) ;=> (:ok)

jimmy 2019-12-20T16:14:21.005800Z

Yes that should.

jimmy 2019-12-20T16:14:57.006Z

And does on master. But maps are different. If you want the semantic for maps you get for vectors use seqable.

eraserhd 2019-12-20T16:15:30.006200Z

OK, respond later, but I have another: (m/search [1 2] (m/not 6) :ok) ;=> (:ok)`

eraserhd 2019-12-20T16:15:36.006400Z

Enjoy your lunch, tho.

noprompt 2019-12-20T17:07:06.006800Z

That last one is correct.

jimmy 2019-12-20T18:45:11.035700Z

In simple cases like this macroexpansion should tell you a decent amount. The tricky cases that we need to be more comprehensive about are sets and maps. They have different semantics than ordered collections and we need to think about those in the face of negation.

eraserhd 2019-12-20T21:11:13.045100Z

wrt "On master the original problem is fixed", I can't find those commits. Did you mean epsilon?

jimmy 2019-12-20T21:11:51.045300Z

Yes. Sorry. I meant epsilon.

eraserhd 2019-12-20T21:21:07.045500Z

(m/search {:a 2, :b 1} (m/not {:a 2}) :ok) ;=> nil is one of those uncovered issues?

jimmy 2019-12-20T21:24:47.045700Z

I was trying to contrast the maven package and git. There are some unreleased fixes.

jimmy 2019-12-20T21:25:07.045900Z

I'm not sure about that one. Sorry on my phone.

eraserhd 2019-12-20T21:25:36.046100Z

ah, ok. np

noprompt 2019-12-20T22:22:16.049300Z

I can cut what’s current in a couple hours if you need @eraserhd

noprompt 2019-12-20T22:22:51.050400Z

Was just trying to pack in a couple more patches before I did that. 😀

eraserhd 2019-12-23T15:27:46.068800Z

@noprompt it would be helpful for me to see the code to understand this m/search thing. I can't upgrade yet, as it will break a lot of my code.

eraserhd 2019-12-23T15:28:32.069Z

I hope other people are not in that boat, and I don't want you to publish early because of me.

jimmy 2019-12-23T16:15:38.069200Z

What code are you hoping to see @eraserhd? The problem with search that we did fix was around search and m/not. Basically search was broken with not because if something failed to match instead of returning FAIL we were returning nil, but then checking if it equaled fail. That is why you were having the weird behavior where find would return something, but search would not. That didn’t fix your example above. (m/search {:a 2, :b 1} (m/not {:a 2}) :ok). What is happing here is that we are trying to do an optimization that makes not break. In this case it is because {:a 2} is a literal. I have a fix for that one. Waiting to hear back from Joel to see if he agrees with the change then should push it up. Right now searching with not on maps seems to have many cases that are broken. That change should fix a good amount of them. But this is an area we need to have better test coverage on. I should have some time in the new two weeks to accomplish that. I will do the same for sets and make sure they behave as expected.

jimmy 2019-12-23T16:23:07.072900Z

I'm really sorry you've encountered this bugs :(

noprompt 2019-12-23T17:33:37.078200Z

@eraserhd that search is working fine. {:a 2} is a submap of the input.

noprompt 2019-12-23T17:34:28.079200Z

The not says it shouldn’t be.

jimmy 2019-12-23T17:35:34.079400Z

Aren't we searching for a map that isn't a submap? Maybe I just don't understand search and not.

jimmy 2019-12-23T17:36:27.079600Z

{:b 1} is a submap we can find by searching that map and it doesn't match the pattern.

noprompt 2019-12-23T19:22:39.079800Z

@eraserhd I think I made a mistake regarding my earlier answer.

eraserhd 2019-12-23T20:41:48.085600Z

I’m on vacation with kids, so I’m erratic answering. Sorry about that... I’ll be back later.

jimmy 2019-12-23T21:17:36.085800Z

No worries. We are still hashing all this stuff out. Trying to make sure we get the semantics of this right rather than just an ad-hoc solution.

dominicm 2019-12-16T21:38:13.011900Z

I hadn't designed it for ad hoc stuff, but it would work for that if called correctly.

noprompt 2019-12-16T21:50:53.012100Z

Hmm… yeah, it looks like the find is wrong.

noprompt 2019-12-16T21:51:03.012300Z

I’ll take a close look.

noprompt 2019-12-16T21:54:39.012500Z

Oh wait, no, its not wrong. The find does seem suspicious.

noprompt 2019-12-16T21:57:42.012700Z

Hmm… gimme a bit.

noprompt 2019-12-16T22:08:25.012900Z

@eraserhd I updated the gist.

noprompt 2019-12-16T22:08:47.013100Z

Lemme know when you get something operational.