test-check

johanatan 2017-11-28T23:27:45.000317Z

hi

johanatan 2017-11-28T23:28:10.000352Z

have you considered the utility of a gen/let which allows either generators or plain values on the right hand side?

2017-11-28T23:31:40.000108Z

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

2017-11-28T23:31:48.000108Z

but I've never liked it 🙂

2017-11-28T23:33:35.000027Z

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

johanatan 2017-11-28T23:35:25.000069Z

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

2017-11-28T23:35:45.000222Z

not what you asked for exactly

2017-11-28T23:35:51.000493Z

I was talking about something else at that point

2017-11-28T23:36:20.000096Z

you'd have to write a macro that expands to gen/let if you wanted to implement the feature yourself

johanatan 2017-11-28T23:36:51.000078Z

what was the something else you were talking about though? perhaps that would interest me if I understood it 🙂

2017-11-28T23:38:58.000281Z

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.

2017-11-28T23:39:29.000097Z

and you can imagine more complex examples where the generators are buried deep in some gnarly data structure

2017-11-28T23:40:28.000338Z

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

johanatan 2017-11-28T23:41:07.000075Z

ah, i see

johanatan 2017-11-28T23:41:11.000139Z

makes sense.

johanatan 2017-11-28T23:41:22.000405Z

for now i'll probably just use gen/return as my need isn't too complicated

👍 1