malli

https://github.com/metosin/malli :malli:
ikitommi 2021-04-01T08:19:59.294500Z

Welcome lazy generators! recursive generators are now orders of magnitude faster, ping @adam678

(time
  (let [schema [:schema {:registry {::A [:tuple [:= :A]]
                                    ::B [:tuple [:= :B]]
                                    ::C [:tuple [:= :C]]
                                    ::D [:tuple [:= :D]]
                                    ::E [:tuple [:= :E] [:ref ::item]]
                                    ::F [:tuple [:= :F] [:ref ::item]]
                                    ::G [:tuple [:= :G] [:ref ::item]]
                                    ::item [:multi {:dispatch first}
                                            [:A ::A]
                                            [:B ::B]
                                            [:C ::C]
                                            [:D ::D]
                                            [:E ::E]
                                            [:F ::F]
                                            [:G ::G]]}}
                ::E]
        valid? (m/validator schema)]
    (is (every? valid? (mg/sample schema {:size 10000})))))
; => "Elapsed time: 230 msecs"

🎉 3
Helins 2021-04-01T08:27:35.294800Z

That was fast! Just tested it with my real world example and it seems to work just perfectly. (Generating WASM instructions where an instruction may contain a list of instructions). Thanks a lot!