This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-28
Channels
- # aleph (7)
- # babashka (13)
- # beginners (10)
- # biff (4)
- # calva (75)
- # cljs-dev (22)
- # clojure (55)
- # clojure-berlin (1)
- # clojure-europe (15)
- # clojure-nl (1)
- # clojure-norway (35)
- # clojure-serbia (1)
- # clojure-uk (2)
- # clojurescript (46)
- # community-development (1)
- # core-async (23)
- # data-science (1)
- # datalevin (2)
- # datascript (10)
- # datomic (11)
- # fulcro (28)
- # helix (12)
- # hyperfiddle (26)
- # introduce-yourself (4)
- # malli (16)
- # off-topic (1)
- # pathom (4)
- # pedestal (1)
- # polylith (12)
- # quil (11)
- # releases (3)
- # scittle (24)
- # shadow-cljs (85)
- # specter (1)
- # sql (9)
- # xtdb (5)
@ikitommi could we move the :=>
guard to properties (before 0.15.0) and consider more flexible argument syntax (later)? I think adding a guard as the final argument locks in the restriction that the args must be a :cat
. These would be nice: [:=> ret]
, [:=> arg1 ret]
, [:=> arg1 arg2 arg3 ret]
. But the guard would then be indistinguishable from the ret
if it's part of the children.
There's a pointer here that seems to suggest it should be in the properties too https://github.com/metosin/malli/issues/608 (this should be referenced in the changelog, but there's a typo at the top of 0.15.0 that references the same issue twice).
This was another option originally, but thought that having a new :->
that doesn’t support guards but would treat the last arg as return, wrap others in :cat
would be cleaner for this. e.g. the following pairs would mean the same:
[:-> :int :int]
[:=> [:cat :int] :int]
:->
[:=> :cat :any]
[:-> :int]
[:=> :cat :int]
[:-> :int [:* :int] :int]
[:=> [:cat :int [:* :int]] :int]
It might be a good opportunity to consider non-cat args like [:=> [:* :int] :int]
or [:=> [:alt :cat [:cat :foo :bar]] :any]
.
OTOH it's a pretty simple rule to remember that :->
always expands to a :cat
no matter what.
(which was the motivation I had, say if you give :->
1 arg which is a regex, you don't need to :cat
)
here's a prototype :->
that supports a :fn
property and always wraps args in :cat
https://github.com/metosin/malli/pull/1027/files
I think perhaps allowing non-cat args in :=>
can be done separately (if ever) and we keep :->
consistently wrapping :cat
.
I'm not a big fan of :->
without children. It starts to look like in an infix op. [:-> :a :-> :b]
I’m holding malli wrong again. The schema [:merge :map :map]
works https://malli.io/?value=%7B%3Aa%2042%7D&schema=%5B%3Amerge%20%3Amap%20%3Amap%5D, but not in my repl.
(comment
(require '[malli.core :as m])
(m/validate [:merge :map :map] {:name "World"})
;=> #error {:message ":malli.core/invalid- … ema {:schema :merge}" , :data {:type :malli.core/invalid-schema, :data {:schema :merge}}} {:type :repl/invoke, :name "<eval>", :js "malli.core.validate. … 77),"World"], null))" , :source "(m/validate [:merge … ap] {:name "World"})" , :source-map-json "{"version":3,↵ "file … name \"World\"})"]}↵" , …}
:rcf)
Ah, I see it now, I need to merge the malli.util schemas. I guess it could be made clearer on the playground which schemas are merged?