Fork me on GitHub

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 ()
   "#(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):

❤️ 2

Look great! There is 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
   [:map-of symbol? [:map
                     [:errors [:sequential
                                [: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! 😍


thanks! there is no schema for it, but could be, PR welcome.


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]]])))


Recall there is mu/equals, using just form checking. Could be improved...


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?


@U055NJ5CC I see that 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?