This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-05
Channels
- # announcements (23)
- # babashka (23)
- # beginners (48)
- # calva (41)
- # clj-kondo (41)
- # cljs-dev (75)
- # cljsrn (5)
- # clojure (85)
- # clojure-europe (46)
- # clojure-nl (2)
- # clojure-spec (70)
- # clojure-uk (4)
- # clojurescript (52)
- # core-async (2)
- # cursive (16)
- # datahike (2)
- # datomic (4)
- # emacs (15)
- # figwheel-main (2)
- # fulcro (5)
- # gratitude (5)
- # helix (14)
- # introduce-yourself (2)
- # jackdaw (13)
- # keyboards (2)
- # lsp (8)
- # luminus (5)
- # malli (3)
- # meander (12)
- # nextjournal (52)
- # off-topic (19)
- # other-languages (1)
- # overtone (3)
- # pathom (4)
- # podcasts-discuss (1)
- # re-frame (6)
- # reitit (1)
- # releases (2)
- # ring (3)
- # sci (22)
- # shadow-cljs (3)
- # specter (1)
- # testing (3)
- # tools-deps (100)
- # uncomplicate (2)
Is there a way to get an "identity" of a quoted meander query such that two queries can be compared for equality and will be equal even if the binding names used are different?
Great question. Ben's reply is good here. You could use something like this to make a name mapping: https://github.com/noprompt/meander/blob/epsilon/src/meander/syntax/epsilon.cljc#L1636-L1646
This could get you to a place where you can tell if two forms are representationally equivalent (almost) but not semantically equivalent. So terms like
[?a [?b 1 ?a]]
[?1 [?2 1 ?1]]
could be found to be equivalent via the method of constructing the rename map deterministically and then applying it.I think this will also work for persistent array maps but, of course, on larger maps a simple =
check may not work.
For fewer traversals, you could try comparing the subnodes
for each of the terms iteratively, building the rename map as you go.
If you're interested in this problem, I've actually wanted a unifier for Meander terms for a little while. It'd be useful.
Because this is very much like unification, we want to see if one term is essentially equivalent to another. This has implications for things like cata
where we could use that information.