gen/let fails `generator?` assertion although all rhs forms in binding vector are indeed generators

Description

Given the following code:

this assertion failure is generated by `(gen/sample entities-and-relations-gen)`:

Environment

ClojureScript, 1.9.293
Clojure, 1.8.0
Mac OS X, running on Node.js v 6.9.1

Activity

Show:
gfredericks
April 4, 2017, 1:54 PM

It looks like you have an error where you're using a (gen/list-distinct ...) expression on the RHS of the gen/let and calling it relations-gen, even though it will be a generated value at that point and not a generator.

Does this make sense?

Jonathan Leonard
April 4, 2017, 4:02 PM

No, `relations-gen` is in fact a generator (`gen/list-distinct ...` returns a generator).

See:

gfredericks
April 4, 2017, 7:39 PM

(gen/list-distinct ...) evaluates to a generator, yes, but when you put a generator on the RHS of gen/let, then the LHS is bound to one of the generated values. Just like entity-set-gen evaluates to a generator but entity-set is not a generator.

gfredericks
April 4, 2017, 7:55 PM

Looking at it closer I imagine what you want here is just to collapse the second and third clauses:

Does this do what you want?

Jonathan Leonard
April 4, 2017, 8:06 PM

Doh! I see.

Yep, that does it. I think I've been too accustomed to using promesa's `alet` which allows both bindings within and [regular] without the monadic context (but I think that might not be possible for `gen/let`).

Declined

Assignee

gfredericks

Reporter

Jonathan Leonard

Labels

None

Approval

None

Patch

None

Priority

Major