test-check 2018-06-26

What's the most idiomatic way to make a generator from a source function (like a constructor)?

(gen/fmap (fn [f] (f)) (gen/return some-constructor))
Seems oblique to say fmap "apply thyself"

that example might be too simple to express your problem, because you can rewrite it as (gen/return (some-constructor))

unless the constructor is nondeterministic

I want to generate fresh instances

(the constructor returns a reify)

in general it's not idiomatic in test.check to be generating non-values, so spec exposes a bit of a mismatch here

but I suppose I've heard similar things from alex about spec

so due to all that, there's not a more idiomatic way to do what you're doing

you might even have to be careful about the same instance getting reused during shrinking

I'm 87% sure that's what would happen if you compose this with other generators

Interesting.... Thanks Gary

👍 this might be an interesting thing to point out in the spec channel