-
Notifications
You must be signed in to change notification settings - Fork 157
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
Feature: In-box shortcut to obtain default generator for a type #638
Comments
The first time I picked up v3 I also struggled finding the correct API. Since |
...or perhaps |
While I like I guess Kurt will have an opinion; I feel the important bits are:
That last piece is something I have grokked to any major degree, and any nudge the common APIs that people will run into via the |
Don't have a a strong opinion. My theory that "explicit is better than implicit, until people find out that explicit means more typing" still going strong I see :) The idea of v3 was that there'd be some integrated shrinking, so In principle putting a method on |
Decided against this. The explicit arbitrary map is an important piece of the new design for extending and dealing with what was "arbitrary registration" before. In particular, Making it explicit that there is an immutable map from types T to If you prefer, there is a |
Apologies for not responding earlier; had been letting it percolate in the hope of coming up with a counter proposal. Writing this in case it helps others, rather than as an actual counter-argument to your decision (which I feel is the correct call)
I don't use anything else in the In general I agree with your call though; concealing pivotal abstractions in the name of discoverability that will only help people that are porting is definitely not ideal. (Would an I currently have this helper blob in most projects and don't see myself removing it: open FsCheck.FSharp
module ArbMap =
let defGen<'t> = ArbMap.defaults |> ArbMap.generate<'t> Ultimately, I use FsCheck in a pretty declarative manner:
I suspect this is not a normal usage pattern, and probably reflects a very naive take on how to wield it... |
While the release notes mention that one can simply use
ArbMap.defaults |> ArbMap.generate
, I find that in practicea) I use that chain a lot in simple test suites
b) I often want to specify the type explicitly, which clutters the chain a lot, but does not make the calling out of the type stick out
c) when porting from V2, the migration path from the previous availability of an equivalent helper is non-obvious (IIRC there was an
Arb.generate
or similar?)Which means I invariably end up sprinkling around helpers like:
Examples of people making helpers and/or not making helpers:
https://github.com/search?q=repo%3Ajet%2Fequinox%20ArbMap.defaults&type=code
https://github.com/search?q=repo%3Afscheck%2FFsCheck%20ArbMap.defaults&type=code
I'm about to make myself an
ArbMap.defGen
helper, but I'd love for an in-box equivalent, so I can delete it and use thatNaming ideas (I assume
AbMap.defGen
does not align with general naming and will not be acceptable):ArbMap.defaultsGenerate
ArbMap.defaultGenerator
ArbMap.defaultGenFor
Arb.defaultsGenerator
- IIRC I looked for ages onArb
for an equivalent in V3 before finding it in the release notes and/or in @pblasucci 's blogThe text was updated successfully, but these errors were encountered: