specter

johanatan 2021-09-13T04:26:57.019900Z

that's close but not quite it. the keys need to match in both. in your example there is no correspondence between structure-1 and structure-2 since the keys do not overlap

johanatan 2021-09-13T04:29:16.022300Z

i was thinking of a zipping the two structures into a sequence where each entry is a three-tuple of the following form: [materizlied_path, value_one, value_two] where either value_one or value_two could be nil when that structure does not have an entry for a specific path that the other one does.

johanatan 2021-09-13T04:29:36.022800Z

then the satisfies would make sure that no nil entries exist in any of those slots for my particular application

2021-09-13T15:40:02.024400Z

Ah, that was unclear from your initial description of the problem. I don't believe specter has a way for you to get a pair of the actual path followed along with the value, which means you would likely need to generate a list of possible paths and iterate over them manually.

2021-09-13T15:41:29.025800Z

Specifically, you could have a way to generate a "materialized path" from each of the types of navigations which navigate to multiple items. Like ALL generating a sequence of paths with nth being called for each integer in (range 0 (count structure)), or MAP-VALS generating a sequence of the keys.

johanatan 2021-09-13T17:42:17.026500Z

Pretty sure it wasn't "unclear from my initial description". Please re-read. Pay particular attention to: a) verify that the same key structure exists in both

johanatan 2021-09-13T17:43:05.026900Z

Ok, yes looks like a challenge wrt generating (or iterating) the paths but that seems surmountable.

johanatan 2021-09-13T17:44:41.027200Z

Thanks for your help!

2021-09-13T19:16:24.027900Z

No problem! Might just be I read that different because even on re-reading it didn't seem clear to me. Definitely not a huge concern though, it got worked out! 🙂

johanatan 2021-09-13T19:32:28.028500Z

btw, i just realized that i already have this keys-in function in my codebase (based on tree-seq), so i probably don't really even need specter for this: https://dnaeon.github.io/clojure-map-ks-paths/

johanatan 2021-09-13T19:33:03.029200Z

i can just get the key sequence paths for m1 and then call get-in for each of them on m2

👍 1
johanatan 2021-09-13T22:36:02.029800Z

arguably not nearly as elegant as whatever the specter solution would be tho 🙂

steveb8n 2021-09-13T23:11:09.030800Z

Q: I’m using a multi-path in a recursive path similar to this example https://github.com/redplanetlabs/specter/wiki/Using-Specter-Recursively#recursively-navigate-to-every-map-in-a-map-of-maps I just discovered that my multi-path expression is working on jvm but not on javascript. The problem seems to be that I have 20 values in the multi-path. has anyone seen a limit of 20 in paths failing like this before?

steveb8n 2021-09-13T23:15:38.031200Z

I also discovered that 21 values in multi-path fails on cljs with “invalid arity” but not on jvm

steveb8n 2021-09-13T23:17:06.031400Z

I wonder if this is the reason? https://github.com/redplanetlabs/specter/blob/master/src/clj/com/rpl/specter/util_macros.clj#L18

steveb8n 2021-09-13T23:19:08.031700Z

workaround: compose the multi-path out of other multi-paths

steveb8n 2021-09-13T23:29:31.031900Z

the bug is that the 20th entry is ignored when used in cljs. if there’s 19 entries then it is fine

steveb8n 2021-09-13T23:44:12.032100Z

asking here before I log a bug, just so I know I’m not missing something stoopid

steveb8n 2021-09-14T00:42:41.032400Z

@nathanmarz do you care about edge case bugs like this?

johanatan 2021-09-14T00:58:26.032600Z

i highly doubt that resource limitations of modern computers really justify that maximum being 20. probably could be just fine with 127 or 1023

johanatan 2021-09-14T00:58:41.032800Z

and way more generous to users

johanatan 2021-09-14T00:58:56.033Z

just to throw my two cents in

johanatan 2021-09-14T00:59:03.033200Z

🙂

nathanmarz 2021-09-14T01:06:55.033400Z

@steveb8n please file a bug report

steveb8n 2021-09-14T01:07:26.033600Z

roger that. will do

steveb8n 2021-09-14T01:18:01.033800Z

https://github.com/redplanetlabs/specter/issues/318