HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Moduleantigen-0.4.0.0Haskell2010

Test.AntiGen

  • 2 types
  • 26 values
  • Packageantigen-0.4.0.0
  • Exports28
  • LanguageHaskell2010
  • LicenceMIT
  • SourceInternal.hs
newtypenewtype AntiGen a
#
Instances5Monad, Functor, Applicative, MonadGen, MonadFree
value(|!) :: Gen a -> Gen a -> AntiGen a
#

Create a negatable generator by providing a positive and a negative generator

value(#!) :: AntiGen a -> Text -> AntiGen a
#

Postfix annotation operator. Annotates an AntiGen with a label that will be included in ZapResult when this generator is zapped.

myGen = positive |! negative #! "sign"
valuezapAntiGen :: Int -> AntiGen a -> Gen a
#

Create a negative generator from an AntiGen by introducing at most n mistakes. If there are no negatable generators in the AntiGen, it will return a positive generator. Also if the number of negatable generators in the AntiGen is lower than n, then the number of negations will be less than n.

Normalized monad combinators

1 declaration
valuereplicateMNorm :: Int -> AntiGen a -> AntiGen [a]
#

Like replicateM, but normalizes the weight of each element by 1/n.

The total weight of the list becomes the average weight of its elements, rather than the sum. This prevents longer lists from having a disproportionately higher chance of being zapped.

AntiGen combinators

15 declarations
valuefaultyNum :: (Eq a, Num a, Arbitrary a) => a -> AntiGen a
#

Returns the provided number.

Negative: returns a value that is not equal to the provided number.

valuefaultyTry :: (Eq a, Arbitrary a) => a -> AntiGen a
#

Returns the provided value

Negative: Generates an arbitrary value that is different from the provided value.

Warning: It uses suchThat, so using it on small types might end up discarding many values.

valuefaultyTryGen :: Eq a => a -> AntiGen a -> AntiGen a
#

Returns the provided value

Negative: Use the generator to generate a random value that is different from the provided value.

Warning: It uses suchThat, so using it on small types might end up discarding many values.

valueantiChoose :: (Integral a, Random a) => (a, a) -> (a, a) -> AntiGen a
#

Generates a value from the first range.

Negative: Generates a value from the second range excluding the first range.