meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
aisamu 2020-05-28T13:02:39.301200Z

I saw this on #malli and thought it would be a great fit for rewrite, but the bit of meander-fu I had acquired has unfortunately dissipated πŸ˜•

[:map
 [:user map?]
 [:profile map?]
 [:nested [:map [:x [:tuple {:deleteMe true} string? string?]]]]
 [:token [string? {:deleteMe true}]]]

;; meander magic => [:map [:user map?] [:profile map?] [:nested :map]]
I could pull it off with Mathematica (will put on the thread), but I can't seem to translate that to Meander.

aisamu 2020-05-28T13:04:14.301300Z

original = 
{"map" ,
 {"user", OddQ}, 
 {"profile", EvenQ}, 
 {"nested", {"map", {"x", {"tuple", "DELETE-ME", StringQ, StringQ}}}},
 {"token", {StringQ, "DELETE-ME"}}};

ReplaceAll[original, {_, {_, "DELETE-ME", ___}} :> Nothing]
{map,{user,OddQ},{profile,EvenQ},{nested,{map}}}

aisamu 2020-05-28T13:09:45.301800Z

{} are lists (just to mess with us), _ is one of anything (regex .), ___ is a list of anything or blank (regex .*) :> is a "binding"

eoliphant 2020-05-28T16:23:00.307100Z

hi, is there a way to handle conditions in a single mapping?

; to get something like this 
{:foo/a "..."
 :foo/b "..."
 :foo/optional ".."}

; to
{:a "..."
 :b "..."}
; or this if :foo/optional is present
 {:a "..."
  :b "..."
  :optional "..."}     
I see that I can do it with conditional matches as arguments to say find, but that seems like it could get repetitive in certain situations

noprompt 2020-05-28T17:47:17.307200Z

I think it’d be good to turn something like this into an issue as well. Bringing in things from other established term rewriting systems is definitely a goal here. πŸ‘

noprompt 2020-05-28T17:51:39.307800Z

@eoliphant In cases like these, search is what I use

(m/search {:foo/a "..."
           :foo/b "..."
           :foo/optional ".."}
  {:foo/a (m/pred string? ?value)}
  [:a ?value]

  {:foo/b (m/pred string? ?value)}
  [:b ?value]

  {:foo/optional (m/pred string? ?value)}
  [:optional ?value])
;; =>
([:a "..."] [:b "..."] [:optional ".."])

noprompt 2020-05-28T17:52:08.308400Z

This yield k/v pairs.

eoliphant 2020-05-28T17:52:18.308700Z

ah I see, then just jam those into a map

noprompt 2020-05-28T17:52:21.309Z

Yah

eoliphant 2020-05-28T17:52:22.309200Z

that makes sense

noprompt 2020-05-28T17:52:51.310100Z

You can also use this β€œtrick” to do validations e.g. where you search for the errors.

eoliphant 2020-05-28T17:52:56.310300Z

thanks. really great stuff by the way.

noprompt 2020-05-28T17:53:21.311100Z

Thanks. I appreciate the compliment. πŸ‘

eoliphant 2020-05-28T17:53:35.311400Z

stuff like this and specter really take the clojure data-fu to the next level

noprompt 2020-05-28T17:54:46.312900Z

It’s a work in progress but I hope its a worthy contribution. πŸ™‚

eoliphant 2020-05-28T17:55:22.313500Z

lol, I think it already is, but looking forward to what’s next

noprompt 2020-05-28T17:56:10.313700Z

Patience is whats next πŸ˜›

noprompt 2020-05-28T17:58:10.315600Z

The pandemic really punched my lights out. The lockdown has definitely put some things in to perspective.

noprompt 2020-05-28T17:58:58.316300Z

With my kids home all the time and not being able to hack as much, its given me a chance to take a moment and think about this open source thing.

noprompt 2020-05-28T17:59:41.317Z

Moral of the story: I need to take better care of myself.

βž• 2
noprompt 2020-05-28T18:00:43.317700Z

I had a ton of stuff planned to release this summer but like everything else there’s gonna be delays.

noprompt 2020-05-28T18:01:36.318400Z

But hopefully not too much delay.

noprompt 2020-05-28T18:01:53.318800Z

I want some better stuff too! πŸ˜„

noprompt 2020-05-28T18:09:51.320700Z

A road map of sorts would be: ensure the epsilon arm is in good shape, solid, and then release zeta sometime within the next year (`zeta` is built using epsilon).

aisamu 2020-05-28T18:37:55.320800Z

Pinging meander folks!

noprompt 2020-05-28T18:41:08.321300Z

I have no idea! πŸ™‚

noprompt 2020-05-28T18:41:48.322100Z

But, hey, we would love more contribution/help with that. I would love to learn more bytecode stuff.

jimmy 2020-05-28T18:49:24.322500Z

I replied on there.

aisamu 2020-05-28T19:16:02.322700Z

Thanks!

noprompt 2020-05-28T22:22:07.323700Z

One small feature that will show up soon is the ability to turn on/off certain compiler features, etc.

noprompt 2020-05-28T22:23:57.325800Z

The first iteration of this won’t be noticeable/immediately useful but after the foundation is set we can add support for alternative stuff like namespaced ::as patterns so that

{:as ?as, :bs ?bs}
will match/build
{:as [1 2 3], :bs [1 2 3]}
or whatever.

noprompt 2020-05-28T22:25:45.327400Z

If we play our cards right we can enable/try out new things, maybe even eliminate some bottlenecks/fix annoyances quickly.

noprompt 2020-05-28T22:28:20.329900Z

The idea will be that we can set these options via meta on the macro forms

^{::m/as-keyword ::m/as}
(m/match {:as [1], :bs [2 3]}
  {:as ?as ::m/as ?it}
  [?as ?it])
;; => [[1], {:as [1], :bs [2 3]}] 

noprompt 2020-05-28T22:29:29.331200Z

The motivation to turn on/off compiler features is so that we can be sure that the semantics are preserved.

noprompt 2020-05-28T22:31:07.332400Z

This was spurred on by a recent bug I discovered in an optimization and that made me paranoid. πŸ™‚

noprompt 2020-05-28T22:32:33.333800Z

Hopefully this checks some confidence boxes for folks too. I know there was some concern about zeta being written with epsilon and epsilon having bugs. I feel the same concern and its why I’m doing this. πŸ‘

noprompt 2020-05-28T22:34:44.334100Z

Transparency! πŸ™‚

noprompt 2020-05-28T22:35:35.334700Z

Also, I think by doing this I can tweak some implementation details in the compiler that might actually be slowing things down.