Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make one_of work with list of non-generators #210

Closed
spicychickensauce opened this issue Mar 10, 2025 · 2 comments
Closed

Make one_of work with list of non-generators #210

spicychickensauce opened this issue Mar 10, 2025 · 2 comments

Comments

@spicychickensauce
Copy link

(from: #209)
I'm using this construct quite often, maybe one_of could be made to support non-generator containing lists as an argument directly?

StreamData.one_of(things |> Enum.map(&StreamData.constant/1))

It already works if all the items are atoms, since those are already automatically generators.

iex(3)> StreamData.one_of([:foo, :bar, :baz]) |> Enum.take(2)
[:foo, :foo]

I don't know if it makes sense to special case one_of. Maybe it's possible to make all non-generators automatically constant generators like already done for atoms and tuples? What would be the consequences of this more drastic change?

@whatyouhide
Copy link
Owner

I forgot that we have member_of 🙃

@spicychickensauce
Copy link
Author

Oops, don't know how I missed that. Thanks for pointing it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants