This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-27
Channels
- # adventofcode (1)
- # announcements (16)
- # babashka (16)
- # beginners (59)
- # calva (13)
- # clj-kondo (7)
- # clj-on-windows (3)
- # cljdoc (5)
- # clojure (85)
- # clojure-dev (5)
- # clojure-europe (4)
- # clojured (3)
- # clojurescript (87)
- # cursive (12)
- # emacs (4)
- # fulcro (15)
- # gratitude (1)
- # introduce-yourself (4)
- # malli (7)
- # off-topic (5)
- # polylith (6)
- # re-frame (15)
- # reagent (2)
- # shadow-cljs (5)
- # tools-deps (6)
- # web-security (2)
- # xtdb (5)
@nbtheduke bumped into that myself. Need to add proper support for the Keyword argument functions now also accept maps
. Could you write an issue of that?
Yep, I can open an issue for it
seems to be that need to add something like :every
and the merge of :map
and :map-of
to get proper support for parsing Clojure syntax.
naive 30min parser for extended Plumatic Schama defn syntax:
(m/parse
Bind
'[a :- :int
[b :- :int [c :- :string :as d :- [:vector :any]] & e :as f]
& {:keys [g h] :as i} :- [:map [:g :int] [:h :int]]])
;{:args [{:arg {:sym a}
; :- :-
; :schema :int}
; {:arg {:vec {:elems [{:arg {:sym b}
; :- :-
; :schema :int}
; {:arg {:vec {:elems [{:arg {:sym c}
; :- :-
; :schema :string}]
; :rest nil
; :as {:as :as
; :sym d
; :schema {:- :-
; :schema [:vector :any]}}}}}]
; :rest {:amp & :form {:arg {:sym e}}}
; :as {:as :as
; :sym f
; :schema nil}}}}]
; :rest {:amp &
; :arg {:arg {:map {:keys [g h] :as i}}
; :- :-
; :schema [:map [:g :int] [:h :int]]}}}
(def Bind
(m/schema
[:schema
{:registry
{"Schema" any?
"Amp" [:= '&]
"As" [:= :as]
"Local" [:and symbol? [:not "Amp"]]
"Map" [:map
[:keys {:optional true} [:vector ident?]]
[:strs {:optional true} [:vector ident?]]
[:syms {:optional true} [:vector ident?]]
[:or {:optional true} [:map-of simple-symbol? any?]]
[:as {:optional true} "Local"]
[:- {:optional true} "Schema"]]
"Vector" [:catn
[:elems [:* "SchematizedArgument"]]
[:rest [:? [:catn
[:amp "Amp"]
[:form "SchematizedArgument"]]]]
[:as [:? [:catn
[:as "As"]
[:sym "Local"]
[:schema [:? [:catn
[:- "Separator"]
[:schema "Schema"]]]]]]]]
"Argument" [:alt
[:catn [:sym "Local"]]
[:catn [:map "Map"]]
[:catn [:vec [:schema [:ref "Vector"]]]]]
"Separator" [:= :-]
"SchematizedArgument" [:alt
[:catn
[:arg "Argument"]]
[:catn
[:arg "Argument"]
[:- "Separator"]
[:schema "Schema"]]]
"Bind" [:catn
[:args [:* "SchematizedArgument"]]
[:rest [:? [:catn
[:amp "Amp"]
[:arg "SchematizedArgument"]]]]]}}
"Bind"]))