This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-20
Channels
- # aleph (78)
- # announcements (13)
- # architecture (8)
- # aws (3)
- # babashka (110)
- # beginners (38)
- # calva (2)
- # clerk (1)
- # clojure (118)
- # clojure-austin (3)
- # clojure-dev (8)
- # clojure-europe (50)
- # clojure-france (2)
- # clojure-nl (1)
- # clojure-portugal (1)
- # clojure-uk (3)
- # clojurescript (101)
- # clr (10)
- # data-science (15)
- # datascript (5)
- # datomic (3)
- # events (1)
- # fulcro (22)
- # graalvm (2)
- # gratitude (3)
- # guix (1)
- # honeysql (1)
- # hyperfiddle (72)
- # jobs (3)
- # lsp (23)
- # malli (18)
- # membrane (29)
- # obb (1)
- # releases (1)
- # ring-swagger (2)
- # shadow-cljs (8)
- # squint (113)
- # xtdb (9)
Does walk not give the custom map data? Do I need to use m/ast
for that? I thought “options” would represent the :label
info i embedded.
(m/walk [:map
[:ts {:label :domain/ts} [:and {:label :domain/specific} :int [:> 0]]]]
(fn [s p c o] (println o) s))
Morning. what do you mean with “custom map data”? the last argument is top-level options. if you want to read the schema properties, you should use (m/properties s)
. For map-entries, there are 2 options:
1. if the schemas has entries, e.g. m/entries
returns non-nil, walk those too
2. use option {::m/walk-entry-vals true}
(m/walk
[:map
[:ts {:label :domain/ts} [:and {:label :domain/specific} :int [:> 0]]]]
(fn [s p c o] (some-> s m/properties println) s)
{::m/walk-entry-vals true})
;{:label :domain/specific}
;{:label :domain/ts}
;=> [:map [:ts {:label :domain/ts} [:and {:label :domain/specific} :int [:> 0]]]]
I’ve just checked bundle size for my cljs app I’ve noticed malli.core is the 2nd largest thing after clojurescript itself. Are there any tips to reducing the impact of malli on bundle size?
really good question! Malli is build for DCE, but multimethods can’t be DCEd. There are examples in malli repo (and a guide in README) for a minimal bundle, with just selected schemas and schema applications (validation). With the minimal set, Malli starts with 1.6KB zipped
to disable default registry, you can:
:closure-defines {malli.registry/type "custom"}
… but then you have to pull the selected schemas at runtime:
(require '[malli.registry :as mr])
(mr/set-default-registry!
{:string (m/-string-schema)
:maybe (m/-maybe-schema)
:map (m/-map-schema)})
if you depend on an optional ns, like malli.generator
- multimethod is mounted for ALL schemas, regardless if that’s needed or not. Not sure if there is a way to make the extensions slimmer.
If all schemas had a concrete class impl, e.g. MapSchema
, AndSchema
etc, the DCE might work also for the extension cases. Not sure. If it did, would be open to changing this in the core.
Super helpful information! This allowed me to reduce malli's footprint from 139.75 kb to 75.09 kb 🙂
I’m using malli to parse/validate a string format that has different types of separators
e.g. a/b/c/d e f g
where part 1 has elements separated by /
and each part is separated by " "
I see instaparse has the ability to ignore certain characters
> In instaparse, you can use angle brackets <>
to hide parsed elements, suppressing them from the tree output.
Does malli have any such capability to ignore certain elements in the parsed output?
It’s not hard to “just ignore those keys” when pulling data out, but it’s a bit annoying to have to invent tags for useless data