malli

https://github.com/metosin/malli :malli:
ikitommi 2020-06-18T04:17:42.072700Z

merged the registries in.

ikitommi 2020-06-18T04:18:06.073100Z

quick poke on the recursive schemas, using :ref:

(def ConsCell
  [:maybe {:id :cons}
   [:tuple int? [:ref :cons]]])

(m/explain ConsCell [1 [2 [3 [4 nil]]]])
; => nil

(m/explain ConsCell [1 [2 [3 [4]]]])
;{:schema [:maybe {:id :cons} [:tuple int? [:ref :cons]]],
; :value [1 [2 [3 [4]]]],
; :errors (#Error{:path [2 2 0 2 2 0 2 2 0 2],
;                 :in [1 1 1],
;                 :schema [:tuple int? [:ref :cons]],
;                 :value [4],
;                 :type :malli.core/tuple-size})}

ikitommi 2020-06-18T04:51:27.076700Z

ok, need to figure out how things like -accept should work with recursive schemas as it’s eager (validation and explain can be both lazy). I guess need to keep a local book keeping not to walk over already walked :refs so that it doesn’t go to infinite loop.

viesti 2020-06-18T05:18:42.076900Z

Nice! :)

2020-06-18T05:23:45.078Z

@ikitommi welcome to the club of infinite loop avoiders :-)

2020-06-18T05:25:20.078100Z

does it still work with cross recursion ? ping refers to pong, and pong refers to ping

ikitommi 2020-06-18T05:45:58.080400Z

does not work yet with mutual recursion, but I think we need :registry schema anyway, like there is :definitions for JSON Schma. Needed anyway for persisting the things. maybe something like:

(explain
  [:registry
   {:schemas [[:maybe {:id :ping} [:tuple [:eq "ping"] [:ref :pong]]]
              [:maybe {:id :pong} [:tuple [:eq "pong"] [:ref :pong]]]]}
   [:ref :pong]]
  ["ping" ["pong" ["ping" nil]]])
; => true

ikitommi 2020-06-18T05:47:33.081200Z

btw, a colourful discussion at the old draft PR: https://github.com/metosin/malli/pull/117

pithyless 2020-06-18T16:07:49.085300Z

I've got

:closure-defines  {malli.registry/type "custom"}
in my shadow-cljs.edn, but still seeing error:
can't set default registry {:type "default"}
Any ideas what I may be forgetting?

pithyless 2020-06-18T16:10:37.086200Z

oh, that's weird - some kind of caching bug; forcing a recompile (after it showed the error) and it went away. ¯\(ツ)

pithyless 2020-06-18T16:17:28.087300Z

The new registry setup allows for easier bootstrapping custom code. :thumbsup:

👍 1
jkent 2020-06-18T17:14:18.089100Z

it doesn’t look like the new first class :string is bundled with the latest reitit [metosin/reitit-malli "0.5.2"] is there reason for this or am I missing something?

pithyless 2020-06-18T18:02:04.092400Z

metosin/reitit-malli on clojars is dependent on malli 0.0.1-SNAPSHOT - theoretically, last version was uploaded yesterday, but maybe you have some caching issues? (I think clojure deps caches any snapshot locally for 24(?) hours). Perhaps try to update your deps to depend directly on latest malli from master?