This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-24
Channels
- # announcements (13)
- # asami (9)
- # aws (3)
- # babashka (13)
- # babashka-sci-dev (7)
- # beginners (32)
- # calva (59)
- # cider (9)
- # clj-kondo (5)
- # cljsrn (14)
- # clojure (98)
- # clojure-brasil (5)
- # clojure-dev (1)
- # clojure-europe (30)
- # clojure-france (12)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-uk (7)
- # clojurescript (20)
- # conjure (2)
- # datahike (7)
- # datalog (38)
- # datomic (29)
- # events (1)
- # fulcro (72)
- # graalvm (1)
- # gratitude (3)
- # helix (7)
- # honeysql (3)
- # improve-getting-started (2)
- # introduce-yourself (1)
- # leiningen (13)
- # lsp (17)
- # malli (11)
- # meander (8)
- # nextjournal (3)
- # off-topic (5)
- # pathom (2)
- # portal (43)
- # rdf (2)
- # re-frame (8)
- # reagent (7)
- # reitit (1)
- # shadow-cljs (27)
- # spacemacs (31)
- # sql (2)
- # tools-deps (3)
- # vim (1)
- # xtdb (12)
two follow-up questions: is there a built-in way to (mi/check)
only one function? Is there a way to pretty-print the result of (mi/check)
?
To check just one function from emacs, I ended up doing:
(defun med/cider-eval-on-top-level-form (fn-str)
(let ((quoted-defn (concat "'" (cider-defun-at-point))))
(cider-interactive-eval (concat "(" fn-str " " quoted-defn ")"))))
(defun malli-check-this ()
(interactive)
(med/cider-eval-on-top-level-form
"#(mi/check {:filters [(mi/-filter-var #{(resolve (second %))})]})"))
About the (mi/check)
pretty-printing issue, I ended up coding my visualization for #portal that looks like this (it happens when I issue the mi/check
command, that I bound to a key):
Look great! There is malli.dev.pretty
for pretty printing things. Could add a handler for check there
Thank you! Mostly, the question I had while doing this was, is there a malli spec for the kind of errors that are generated by (mi/check)
?
I temporarily shimmed it as:
(def check-error
(m/schema
[:map-of symbol? [:map
[:errors [:sequential
[:map
[:check [:map
[:malli.generator/explain-output :any]]]]]]]]))
but maybe you have something more complete. Btw, I'm really liking malli, it's really well designed! 😍Is the following untrue because what's compared is just the addresses in the references?
(deftest optionalize-db-generated-keys
(= (malli.util/optional-keys [:map [:key [:int]]])
(malli/schema [:map [:key {:optional true} [:int]]])))
I asked this quite some time ago, and IIRC at the time it wasn't possible: what's the way of writing a spec for the function (defn add [x y] ...)
so that we check that the result is bigger than both x
and y
?
oh yeah I found a relevant issue https://github.com/metosin/malli/issues/608
@U055NJ5CC I see that https://github.com/metosin/malli/blob/master/src/malli/core.cljc#L2443-L2445 is the place in which the function is instrumented, and that's probably where a check for the new :fn
key of :=>
should go. But what else should be changed?