HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulequickcheck-dynamic-4.0.1Haskell2010

Test.QuickCheck.DynamicLogic.Quantify

This module defines Quantifications, which are used together with forAllQ in DynamicLogic. A `Quantification t` can be used to generate a t, shrink a t, and recognise a generated t.

  • 2 types
  • 1 class
  • 15 values
datadata Quantification a
#

A Quantification over a type a is a generator that can be used to generate random values in DL scenarios.

A Quantification is similar to a Arbitrary, it groups together:

  • A standard QuickCheck _generator_ in the Gen monad, which can be "empty",

  • A _shrinking_ strategy for generated values in the case of a failures ensuring they stay within the domain,

  • A _predicate_ allowing finer grained control on generation and shrinking process, e.g in the case the range of the generator depends on trace context.

NOTE: Leaving the possibility of generating Nothing is useful to simplify the generation process for elements or frequency which may normally crash when the list to select elements from is empty. This makes writing DL formulas cleaner, removing the need to handle non-existence cases explicitly.

Instances2Quantifiable, Quantifies
valueelementsQ :: Eq a => [a] -> Quantification a
#

Pick a random value from a list. Treated as an empty choice if the list is empty:

Plutus.Contract.Test.ContractModel.forAllQ (elementsQ []) == empty
valuemapQ :: (a -> b, b -> a) -> Quantification a -> Quantification b
#

Quantification is not a Functor, since it also keeps track of the range of the generators. However, if you have two functions to :: a -> b from :: b -> a satisfying from . to = id you can go from a quantification over a to one over b. Note that the from function need only be defined on the image of to.

valuewithGenQ :: Gen a -> (a -> Bool) -> (a -> [a]) -> Quantification a
#

Construct a `Quantification a` from its constituents. Note the predicate provided is used to restrict both the range of values generated and the list of possible shrinked values.

Wrap a Quantification in HasNoVariables to indicate that you know what you're doing and there are no symbolic variables in the thing you are quantifying over. WARNING: use this function carefully as there is no guarantee that you won't get bitten by very strange failures if you were in fact not honest about the lack of variables.

classclass QuantifyConstraints (Quantifies q) => Quantifiable q where
#

Generalization of Quantifications, which lets you treat lists and tuples of quantifications as quantifications. For instance,

  ...
  (die1, die2) <- Plutus.Contract.Test.ContractModel.forAllQ (chooseQ (1, 6), chooseQ (1, 6))
  ...

Associated types

Methods

Instances6Quantifiable