-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add ability to override custom types in auto-generator #19
Comments
Any thoughts on this? |
I apologize for the delay, I've been busy. I'll get back to this soon. /cc @jystic |
There should be quite a few ways of doing this, and I think I'm not convinced with any of them:
|
I'd start looking for the most type safe approach which immediately excludes the emulation of Haskell typeclasses and the dictionary lookup. |
I haven't thought too hard on this, but recursively auto-generating custom types seems inherently un-typesafe to me. How could it be made type-safe? Could you share an example? |
Hmm, I just thought of another way to solve the specific problem of stack overflow when auto-generating recursive types (which is the main reason I wanted this override functionality in the first place). We can add a For example, say we have a What do you think? |
Nearly finished with an implementation of what I described above. Seems to work brilliantly. Will create a PR when I'm done, need to test it thoroughly. |
On mobile right now, but looking forward to your PR. |
I'm interested in this feature. In my case, attempting to Of the 5 options given, I feel like I only understand the dictionary approach. I'd pass a list of Generators as a new field on @moodmosaic have your thoughts evolved on this issue? |
How does reflection enter into the picture? Are you talking about using reflection to obtain a list of the defined generators in the test library, and fill a dictionary with those? @moodmosaic I don't see any important downsides to the dictionary approach. Could you elaborate, if you still hold this position? The only "downside" I can see is that the user, when using |
I can't remember (it's been ~3 years) but it seems strange to me right now why I excluded the dictionary approach. (I could understand that excluding the typeclass emulation sounds reasonable.) I'd just go with the dictionary approach now. |
I think this functionality would provide a workaround for hedgehogqa/fsharp-hedgehog#249. |
Yep. (Though I think we ought to provide out-of-the-box primitive generators.) |
Agree. I just think it is interesting to see the connection. |
So in this case the user would pass the generator for that type through the dictionary. |
I hope to have implemented this feature during the weekend. I will make a PR so you can have a look at it. Also I think I'll wait with releasing a new version until hedgehogqa/fsharp-hedgehog#249 is fixed, so I can include changes that depend on that, too (specifically, adding support for |
It would be great if the user could specify overrides for any complex type they desire. For example, say
Customer
is a type that has a field of typeCustomer list
(sub-customers of the current customer). This is recursive and (currently) needs a specifically designed generator to avoid stack overflow. Say then that I want to generate anOrder
type which, among other things, contains aCustomer
, then I'd want to just sayauto<Order>(...)
and somehow specify that I wantCustomer
objects to be generated using my specific generator, and otherwise the defaults are fine.I'm not sure how to do this though, or if it is easy/feasible/possible.
The text was updated successfully, but these errors were encountered: