This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-07
Channels
- # announcements (6)
- # babashka (17)
- # beginners (72)
- # calva (27)
- # cider (26)
- # circleci (6)
- # clj-kondo (35)
- # cljdoc (3)
- # clojure (22)
- # clojure-australia (2)
- # clojure-dev (45)
- # clojure-france (2)
- # clojure-italy (2)
- # clojurescript (60)
- # conjure (16)
- # cursive (8)
- # datahike (10)
- # datascript (1)
- # datomic (3)
- # emacs (5)
- # fulcro (16)
- # graalvm (4)
- # honeysql (1)
- # joker (10)
- # luminus (3)
- # malli (7)
- # off-topic (28)
- # pathom (4)
- # pedestal (2)
- # polylith (1)
- # re-frame (6)
- # reagent (9)
- # reveal (4)
- # shadow-cljs (48)
- # slack-help (1)
- # tools-deps (30)
- # vim (24)
Not sure how useful the function schema checking is in real life (maybe for tooling?), but here’s the wip:
(require '[malli.generator :as mg])
(def check
(mg/function-checker
[:function
[1 [:=> [:cat :int] :int]]
[2 [:=> [:cat :int :int] [:int {:max 10}]]]]))
(check
(fn
([x] x)
([x y] (mod (+ x y) 10))))
; => nil
(check
(fn
([x] x)
([x y] (+ x y))))
;({:total-nodes-visited 18,
; :depth 6,
; :pass? false,
; :result false,
; :result-data nil,
; :time-shrinking-ms 0,
; :smallest [(0 11)],
; :malli.core/schema [:=> [:cat :int :int] [:int {:max 10}]]})
(check
(fn
([x y] (mod (+ x y) 10))))
;({:total-nodes-visited 0,
; :depth 0,
; :pass? false,
; :result "Wrong number of args (1) passed to: user/eval97462/fn--97463",
; :time-shrinking-ms 0,
; :smallest [(0)],
; :malli.core/schema [:=> [:cat :int] :int]})
this @UG9U7TPDZ, in master, will be released soon.
hi, I search a little bit long before finding that representing date in malli could be easily done with inst? Is it a recommended approach? I have a doubt as I would expect to find a reference of that in the malli doc which I did not.
inst?
is ok, but see https://github.com/metosin/malli/issues/49