Fork me on GitHub
#test-check
<
2017-11-28
>
johanatan23:11:10

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

gfredericks23:11:40

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

gfredericks23:11:48

but I've never liked it 🙂

gfredericks23:11:35

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

johanatan23:11:25

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

gfredericks23:11:45

not what you asked for exactly

gfredericks23:11:51

I was talking about something else at that point

gfredericks23:11:20

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

johanatan23:11:51

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

gfredericks23:11:58

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.

gfredericks23:11:29

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

gfredericks23:11:28

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

johanatan23:11:11

makes sense.

johanatan23:11:22

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