You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following a quick discussion from #324, this issue is being created to provide generalized formatting for values from a Gen<'a>.
Ideally, we'd change the Gen<'a> type to be a record, and add a formatter field that looks like 'a -> string. To maintain compatibility, this field should have a default value of sprintf "%A". Another function should be exposed to override this default, withFormatter : ('a -> string) -> Gen<'a> -> Gen<'a>.
Any values from a generator that are formatted should use the provided formatter.
The text was updated successfully, but these errors were encountered:
Ideally, we'd change the Gen<'a> type to be a record, and add a formatter field that looks like 'a -> string.
I am not convinced that this is the right approach. My first impression is that we should make a change like that to Property<_> or the functions of Property. It is those functions that want to string representation.
Ideally, we'd change the Gen<'a> type to be a record, and add a formatter field that looks like 'a -> string.
I am not convinced that this is the right approach. My first impression is that we should make a change like that to Property<_> or the functions of Property. It is those functions that want to string representation.
Gen would have better knowledge of the 'a being generated, I don't think Property is parameterized on the type being generated. I think of it as "gen can make a thing, and also a string representation of the thing".
How does Haskell-Hedgehog solve this problem?
They probably just use type classes, like Show and don't have this problem at all. The equivalent in .NET would be to override ToString, which we can't do for types we don't control.
I'm thinking about the interplay between GenConfig and PropertyConfig. Might we have something like PropertyConfig.withGenConfig, or is that too much 🤪
Also, would it be reasonable to eventually add size and/or seed to GenConfig?
...and if so, how would we explain to users why they're on GenConfig and not PropertyConfig? 😅
Following a quick discussion from #324, this issue is being created to provide generalized formatting for values from a
Gen<'a>
.Ideally, we'd change the
Gen<'a>
type to be a record, and add aformatter
field that looks like'a -> string
. To maintain compatibility, this field should have a default value ofsprintf "%A"
. Another function should be exposed to override this default,withFormatter : ('a -> string) -> Gen<'a> -> Gen<'a>
.Any values from a generator that are formatted should use the provided formatter.
The text was updated successfully, but these errors were encountered: