Fork me on GitHub
#malli
<
2023-05-02
>
Ben Sless05:05:50

Something I'm missing with generators is schemas algebra, there are scenarios where I'd want to mix a static schema with a potentially dynamic one and generate from that. Instead of writing ad hoc schemas or combinators it would be nice if it were already part of schemas, either in the algebra level, or that generators will also provide how to gen/bind with them (e.g. and) Thinking about quickcheck with malli

ikitommi06:05:44

Interesting. How would you define the dynamic part?

ikitommi06:05:36

there is :gen/schema which is currently just a value. supporting a function (fn [schema options] …) there would allow one to access the current schema.

Ben Sless06:05:23

In the context of quickcheck, the problem starts with needing to generate data based on the current state. You could write your generators ad-hoc and compose those, but what I want is to use the existing state as a "kernel", then provide it to a generator to fill-out the missing bits. Case example: we simulate a flow of user creation and log in. The correct implementation must generate a log in request for already existing user IDs (logical join?) Currently I'd need to create a generator that generates user request, samples and id, and overrides it in the request. What I want is [:and [:map [:id id]] UserLogIn]

escherize15:05:56

I’m curious to learn more about recursive generators with refs and :malli.core/potentially-recursive-seqex. Besides https://github.com/metosin/malli/blob/master/src/malli/generator.cljc#L186-L281 is there more info about limitations / tricks for creating them?

escherize15:05:29

gathering some more info, there’s this thread too: https://clojurians-log.clojureverse.org/malli/2022-12-04