-
Notifications
You must be signed in to change notification settings - Fork 37
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
Optional labelled parameter in functions #75
Comments
That's a good remark indeed. Perhaps it's time we start designing 1.0, the library has been mostly stable for years now. I'd probably rather have |
Yes, that's a good design for sure. |
Can you elaborate why you find them tricky to use? # Gen.generate1 Gen.string;;
- : string = ":Í\0025�gª;N"
# Gen.generate1 (Gen.string ~gen:(Gen.oneofl ['a';'b']));;
- : string = "aaabbababbbbbbbaabbbbaabbbbabbbabaaaaabaabaaabaababaabaaabba" |
@jmid the trickiness comes from trying to get a
|
optional parameters not followed by a positional parameters are, in effect, not really optional. So that's a design mistake that's on my. However we could simply provide new functions (like |
OK. Thanks for clarifying. # (Gen.string : string Gen.t);;
- : string Gen.t = <fun> |
@jmid that's a good workaround, thanks. |
a PR to enrich the API would be seen favorably 😉 |
@c-cube But they are followed by a positional parameter aren't they? A generator type is, by definition, taking a state parameter: # #show Gen.t;;
type nonrec 'a t = Random.State.t -> 'a |
@jmid yes, but in this case it'll always be used as a partial application, so the argument still stands. |
These are more explicit versions of `QCheck.Gen.string` without optional parameters. Fixes c-cube#75
These are more explicit versions of `QCheck.Gen.string` without optional parameters. Fixes c-cube#75
These are more explicit versions of `QCheck.Gen.string` without optional parameters. Fixes c-cube#75
I've come across a couple of functions in
QCheck.Gen
which have only optional parameters:Not sure if there are more throughout the library. Functions with only optional labelled parameters are tricky to use :-) would there be some receptiveness to adding a 'bookend'
()
parameter to them for 1.0? If we're going by SemVer, backward-incompatible changes are allowed in a major version...The text was updated successfully, but these errors were encountered: