Hoogle Search
Within LTS Haskell 24.63 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
class
GValidSubtermsIncl (f :: Type -> Type) agenvalidity Data.GenValidity No documentation available.
class Validity a =>
GenValid agenvalidity Data.GenValidity A class of types for which valid values can be generated to be valid.
How to instantiate GenValid
Step 1: Try to instantiate GenValid without overriding any functions. It is possible that, if few values are valid or if validity checking is expensive, the resulting generator is too slow. In that case, go to Step 2. Step 2: Consider using genValidStructurallyWithoutExtraChecking and shrinkValidStructurallyWithoutExtraFiltering to speed up generation. This only works if your type has a derived or trivial Validity instance. Step 3: If that still is not fast enough, consider writing your own generator and shrinking function. Make sure to generate any possible valid value, but only valid values.A note about Arbitrary
If you also write Arbitrary instances for GenValid types, it may be best to simply useinstance Arbitrary A where arbitrary = genValid shrink = shrinkValid
gGenValid :: GGenValid f => Gen (f a)genvalidity Data.GenValidity No documentation available.
gValidRecursivelyShrink :: GValidRecursivelyShrink f => f a -> [f a]genvalidity Data.GenValidity No documentation available.
gValidSubterms :: GValidSubterms f a => f a -> [a]genvalidity Data.GenValidity No documentation available.
gValidSubtermsIncl :: GValidSubtermsIncl f a => f a -> [a]genvalidity Data.GenValidity No documentation available.
genValid :: GenValid a => Gen agenvalidity Data.GenValidity Generate a valid datum, this should cover all possible valid values in the type The default implementation is as follows:
genValid = genValidStructurally
To speed up testing, it may be a good idea to implement this yourself. If you do, make sure that it is possible to generate all possible valid data, otherwise your testing may not cover all cases.genValidStructurally :: (Validity a, Generic a, GGenValid (Rep a)) => Gen agenvalidity Data.GenValidity Generate a valid value by generating all the sub parts using the Generic instance, and trying that until a valid value has been generated
genValidStructurally = genValidStructurallyWithoutExtraChecking `suchThat` isValid
This is probably the function that you are looking for. If you do use this function to override genValid, you probably also want to use shrinkValidStructurally to override shrinkValid.genValidStructurallyWithoutExtraChecking :: (Generic a, GGenValid (Rep a)) => Gen agenvalidity Data.GenValidity Generate a valid value by generating all the sub parts using the Generic instance, This generator is _not_ guaranteed to generate a valid value. This is probably _not_ the function that you are looking for when overriding genValid _unless_ the type in question has no _extra_ validity constraints on top of the validity of its sub parts.
shrinkValid :: GenValid a => a -> [a]genvalidity Data.GenValidity Shrink a valid value. The default implementation is as follows:
shrinkValid = shrinkValidStructurally
It is important that this shrinking function only shrinks values to valid values. If shrinkValid ever shrinks a value to an invalid value, the test that is being shrunk for might fail for a different reason than for the reason that it originally failed. This would lead to very confusing error messages.