This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-28
Channels
- # babashka (29)
- # beginners (179)
- # bristol-clojurians (1)
- # calva (9)
- # chlorine-clover (47)
- # cider (57)
- # clj-kondo (1)
- # cljs-dev (13)
- # clojure (241)
- # clojure-europe (9)
- # clojure-nl (4)
- # clojure-norway (88)
- # clojure-spec (4)
- # clojure-uk (15)
- # clojurescript (211)
- # clojutre (1)
- # community-development (8)
- # core-async (1)
- # datomic (31)
- # figwheel-main (33)
- # fulcro (29)
- # ghostwheel (6)
- # graalvm (11)
- # graphql (12)
- # instaparse (4)
- # jobs (1)
- # jobs-discuss (17)
- # leiningen (7)
- # malli (6)
- # meander (38)
- # off-topic (208)
- # onyx (6)
- # re-frame (23)
- # reagent (8)
- # shadow-cljs (61)
- # spacemacs (10)
- # sql (5)
- # yada (5)
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.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}}}
{}
are lists (just to mess with us),
_
is one of anything (regex .
),
___
is a list of anything or blank (regex .*
)
:>
is a "binding"
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. 👍
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@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 ".."])
You can also use this “trick” to do validations e.g. where you search for the errors.
The pandemic really punched my lights out. The lockdown has definitely put some things in to perspective.
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.
I had a ton of stuff planned to release this summer but like everything else there’s gonna be delays.
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
).
But, hey, we would love more contribution/help with that. I would love to learn more bytecode stuff.
I replied on there.
One small feature that will show up soon is the ability to turn on/off certain compiler features, etc.
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.If we play our cards right we can enable/try out new things, maybe even eliminate some bottlenecks/fix annoyances quickly.
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]}]
The motivation to turn on/off compiler features is so that we can be sure that the semantics are preserved.
This was spurred on by a recent bug I discovered in an optimization and that made me paranoid. 🙂