hi
have you considered the utility of a gen/let
which allows either generators or plain values on the right hand side?
there are a lot of places in the API where that sort of thing could be done; my feeling is that it would cause more confusion than it would add value; and the ambiguity of it (a generator is also a value, sort of) is off-putting to me
a general rant about that sort of thing here: https://brehaut.net/blog/2013/duck_wrapping
that said, I did do exactly that in the body of gen/let
but I've never liked it 🙂
the most useful thing I can imagine in this direction is being able to create a complex nested data structure where some of the leaves are generators and others aren't but that sort of feature could be written as just a function that takes such a data structure and returns the generator you want, and calling an extra function wouldn't be much of a burden at than point since you by definition already have a big chunk of code
i'm not seeing how that feature could be written as just a function? since there can be dependencies between the nodes of the let
not what you asked for exactly
I was talking about something else at that point
you'd have to write a macro that expands to gen/let
if you wanted to implement the feature yourself
what was the something else you were talking about though? perhaps that would interest me if I understood it 🙂
a function that you could use for your use case like so:
(gen/let [x (generatorfy something)]
...)
which is no easier than writing gen/return
; but it would have additional magical features so that you could also write (generatorfy [:foo gen/nat 42])
and get a generator for things like [:foo 12 42]
and [:foo 19 42]
and etc.and you can imagine more complex examples where the generators are buried deep in some gnarly data structure
btw if it would be useful for you to have anything of this sort in https://github.com/gfredericks/test.chuck so you don't have to maintain it yourself, I'm happy to accept PRs
ah, i see
makes sense.
for now i'll probably just use gen/return
as my need isn't too complicated