This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-22
Channels
- # announcements (1)
- # aws (11)
- # babashka (10)
- # beginners (49)
- # calva (32)
- # cljsrn (3)
- # clojure (123)
- # clojure-australia (1)
- # clojure-dev (2)
- # clojure-europe (27)
- # clojure-spec (1)
- # clojurescript (22)
- # clojutre (1)
- # code-reviews (1)
- # conjure (3)
- # editors (32)
- # emacs (3)
- # graalvm (12)
- # kaocha (1)
- # lsp (1)
- # malli (2)
- # off-topic (1)
- # schema (2)
- # shadow-cljs (32)
- # spacemacs (6)
- # tools-deps (4)
Hey! I have been doing a lot of work involving generating recursive data. This is a space where actually, from what I see, neither Spec nor Malli have a working solution. Any trivial example is already too much and generation gets completely out of hand. However I haven't used Spec in a while so I might be mistaken. I'd appreciate your thoughts and comments, especially if you have encountered that kind of problems. Albeit extremely simple, with a pretty standard size of 30, generating a single instance of this example results commonly in 1000-3000 leaves (nested vectors containing that much booleans):
(s/def ::bool
boolean?)
(s/def ::vec
(s/coll-of ::data))
(s/def ::data
(s/or :bool ::bool
:vec ::vec))
There is an "exponential explosion" so that such definitions to not reflect the size linearly but rather exponentially. I tried explaining it thoroughly here and how test.check
solves it with recursive-gen
(the fact it is a Malli issue is irrelevant): https://github.com/metosin/malli/issues/452
So, surprisingly, it is somewhat impossible to generate truly random Clojure values where collection items can be collections as well. Unless I am of course missing something, so here I am :)