meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
noprompt 2020-01-14T00:37:39.055800Z

Should we have a clojure.core/deref pattern?

(m/match (atom {:visits 100}) 
  @{:visits ?visits}
  [:p "Visits: " ?visits])
;; => [:p "Visits: " 100]

timothypratley 2020-01-14T16:53:01.056600Z

so… syntax sugar for (m/pred #(satisfies? IDeref %) (m/app deref <thing>)) ???

timothypratley 2020-01-14T16:55:04.057Z

pros: it seems useful and convenient 🙂 cons: are there risks in conflating evaluation time with matching? I can’t think of any concrete risks here.

noprompt 2020-01-14T18:20:09.057600Z

Yeah, something like that. I don’t know if there are any real cons apart from stealing clojure.core/deref.

noprompt 2020-01-14T18:20:45.057900Z

Which actually might be a bad idea.

noprompt 2020-01-14T18:21:44.058100Z

Some folks may not realize that @ and clojure.core/deref are the same thing.

timothypratley 2020-01-14T18:28:06.058700Z

I guess from a data perspective, one could argue that @ is not data, but FWIW I also think that the idea of promises/future things is not a Clojure only thing, and a pretty useful idea (laziness too).

dominicm 2020-01-14T10:42:33.056400Z

m/app can do that right? Is it worth hanging onto @ for something custom?

1☝️
timothypratley 2020-01-14T16:53:01.056600Z

so… syntax sugar for (m/pred #(satisfies? IDeref %) (m/app deref <thing>)) ???

timothypratley 2020-01-14T16:55:04.057Z

pros: it seems useful and convenient 🙂 cons: are there risks in conflating evaluation time with matching? I can’t think of any concrete risks here.

timothypratley 2020-01-14T16:56:34.057200Z

any thoughts on what @ might otherwise mean?

dominicm 2020-01-14T17:25:08.057400Z

Well for one thing, I might want to match the literal symbol clojure.core/deref. So maybe something funk would be bad

noprompt 2020-01-14T18:20:09.057600Z

Yeah, something like that. I don’t know if there are any real cons apart from stealing clojure.core/deref.

noprompt 2020-01-14T18:20:45.057900Z

Which actually might be a bad idea.

noprompt 2020-01-14T18:21:44.058100Z

Some folks may not realize that @ and clojure.core/deref are the same thing.

noprompt 2020-01-14T18:24:25.058300Z

Yeah… We have the same “problem” with ~ .

noprompt 2020-01-14T18:25:07.058500Z

At the same time, parsing ~ in a macro form specially is an uncommon but useful technique.

timothypratley 2020-01-14T18:28:06.058700Z

I guess from a data perspective, one could argue that @ is not data, but FWIW I also think that the idea of promises/future things is not a Clojure only thing, and a pretty useful idea (laziness too).

timothypratley 2020-01-14T18:29:08.058900Z

Just as a data point of 1 I have no problem quoting colliding symbols! 🙂

timothypratley 2020-01-14T18:32:48.059100Z

The fact that the Clojure reader expands @ does add a curveball, in that @x === (clojure.core/deref x) but I don’t see any immediate inconsistencies

timothypratley 2020-01-14T18:34:56.059300Z

Oh well '@x means '(clojure.core/deref x) doesn’t it? So either the operator would have to be smart or you can’t quote them like that :thinking_face: that does seem tricky!

timothypratley 2020-01-14T18:35:43.059500Z

i.e. ('clojure.core/deref ?x) is how it should be treated, but that’s not what it is.

timothypratley 2020-01-14T18:36:31.059700Z

but really '@x doesn’t make any sense anyhow sorry for the noise here I’m just trying to wrap my head around it! 🙂

noprompt 2020-01-14T18:59:19.059900Z

> Just as a data point of 1 I have no problem quoting colliding symbols! I agree. Thats what ' is there for.

'@x
is parsed as
'(clojure.core/deref x)
however this is not a problem because that is actually the form
(quote (clojure.core/deref x))
and meander respects quote so theres not problem there.

noprompt 2020-01-14T19:00:59.060200Z

So

(match '(clojure.core/deref toast) '@toast true) ;; => true

noprompt 2020-01-14T19:01:46.060500Z

and

(me/match '(clojure.core/deref toast) @toast true) ;; => true