meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
eraserhd 2019-12-17T04:13:01.013400Z

I'm not sure I understand. My model suggests that m/find = first . m/search (the docstring for m/find says as much, AFICT), so seeing m/find return a value when m/search doesn't seem right.

eraserhd 2019-12-17T05:05:32.013800Z

Ok, I updated the gist with the minimal data and some results poking at it. I still can't model what is happening, though.

jimmy 2019-12-17T05:11:05.014Z

I think it is a bug. Looking at some codegen now and I think there is some bad code generated in search. Trying to track it down a bit more

jimmy 2019-12-17T05:41:55.014200Z

@noprompt and I are agreed that it is a bug. Here’s my minimal reproducible case.

(let [prod-snapshot 
      {1 2
       2 1
       3 5
       5 3}]
  (m/search prod-snapshot
    {?p _
     & (m/not {_ ?p})} 
    ?p))
=>
()
There is some bad codegen that is making search stop short when it should continue searching.

eraserhd 2019-12-17T05:55:18.014500Z

I expect that m/search to be empty. Are you saying there's a bug in the m/find version of that?

eraserhd 2019-12-17T05:59:11.014700Z

I'm not entirely sure my expectations are right, but m/find for that returns 5, and I expect nil, while m/search for that I would expect to be ().

jimmy 2019-12-17T05:59:45.014900Z

No, the search there should not be empty. I intentionally set it up so that should return back all the keys. Consider 1. Remove [1 2] from the map. We are left with [[2 1] [3 5] [5 3]]. Now we are saying find me some case where 1 is not the value. Well, there is such a case. In fact, there are two. [3 5] [5 3]

eraserhd 2019-12-17T06:00:49.015100Z

"find me some case where 1 is not the value" is {_ (m/not ?p)}, though, right?

jimmy 2019-12-17T06:02:58.015300Z

Yes

jimmy 2019-12-17T06:03:20.015500Z

But also (m/not {_ ?p})

eraserhd 2019-12-17T06:03:32.015700Z

hmmm

eraserhd 2019-12-17T06:03:55.015900Z

I'm skeptical, but not sure I can prove it.

jimmy 2019-12-17T06:04:48.016100Z

(m/search {1 2
           2 3}
  (m/not {_ 2})
  :yep)
=>
:yep

eraserhd 2019-12-17T06:05:40.016500Z

I get nil

jimmy 2019-12-17T06:06:07.016700Z

One second need to restart my repl

jimmy 2019-12-17T06:08:33.016900Z

Let’s start here.

(m/find {1 2 2 3}
   {_ 2}
  :yep)
=> :yep

eraserhd 2019-12-17T06:09:27.017100Z

got same, and me brain agrees.

jimmy 2019-12-17T06:09:30.017300Z

Maps in meander work a lot like sets.

(m/find #{1 2 3}
   #{1}
  :yep)

=> :yep

eraserhd 2019-12-17T06:10:08.017500Z

got same, and me brain still agrees :)

jimmy 2019-12-17T06:10:20.017700Z

So in that case we are saying that there exists some value that is 2. We are not saying all values are 2.

eraserhd 2019-12-17T06:10:38.018Z

right

jimmy 2019-12-17T06:12:07.018200Z

Okay, hold on let me formulate my thoughts

eraserhd 2019-12-17T06:12:15.018400Z

ok

jimmy 2019-12-17T06:15:29.018600Z

Okay, so what we are saying with (m/not {_ 2}) is do I have a map such that {_ 2} will not match it. So what maps are those? Maps without any values that are 2.

jimmy 2019-12-17T06:15:49.018800Z

Or to put it another way a map that does not have a 2 as a value

jimmy 2019-12-17T06:18:03.019Z

I’ve got to head to bed. But hopefully that makes sense. Joel is working on fixing the issue now.

eraserhd 2019-12-17T06:18:19.019200Z

I think this statement is how I've been interpreting it, and why I think m/search should return () above.

eraserhd 2019-12-17T06:18:30.019400Z

g'night. past my bedtime too :D

jimmy 2019-12-17T06:21:19.019600Z

I realized that I said it wrong. But no time to say it right. I will revisit with an explanation tomorrow.

jimmy 2019-12-17T06:21:35.019800Z

Negation is hard

jimmy 2019-12-17T06:25:38.020Z

The best way to think about it is in terms of submaps. Is there sub map that fails to match? Yes there is. So it matches.

eraserhd 2019-12-17T06:28:46.020200Z

This implies there are patterns P for which (m/and P (m/not P)) match.

noprompt 2019-12-17T07:26:00.020400Z

Alrighty. Thanks to some help from Jimmy, I think I should have a patch for this

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.