Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data AdaSymbolPresence
- newtype GenCurrencySymbol (p :: AdaSymbolPresence) = GenCurrencySymbol CurrencySymbol
- newtype GenValue (adaMod :: Type -> Type) (otherMod :: Type -> Type) = GenValue Value
- data TimeDelta (mod :: Type -> Type) (n :: Nat)
- timeDeltaProperty :: forall (n :: Nat) (mod :: Type -> Type). Coercible (mod POSIXTime) Integer => (POSIXTime -> Property) -> POSIXTime -> TimeDelta mod n -> Property
- withTimeDelta :: forall (n :: Nat) (mod :: Type -> Type) (r :: Type). Coercible (mod POSIXTime) Integer => (Maybe POSIXTime -> r) -> POSIXTime -> TimeDelta mod n -> r
Types
data AdaSymbolPresence Source #
Type-level marker to indicate whether a GenCurrencySymbol
can have an ADA
CurrencySymbol
inside it or not.
Since: 2.1.3
Instances
Show AdaSymbolPresence Source # | Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers | |
Eq AdaSymbolPresence Source # | Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers (==) :: AdaSymbolPresence -> AdaSymbolPresence -> Bool Source # (/=) :: AdaSymbolPresence -> AdaSymbolPresence -> Bool Source # | |
Ord AdaSymbolPresence Source # | Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers compare :: AdaSymbolPresence -> AdaSymbolPresence -> Ordering Source # (<) :: AdaSymbolPresence -> AdaSymbolPresence -> Bool Source # (<=) :: AdaSymbolPresence -> AdaSymbolPresence -> Bool Source # (>) :: AdaSymbolPresence -> AdaSymbolPresence -> Bool Source # (>=) :: AdaSymbolPresence -> AdaSymbolPresence -> Bool Source # max :: AdaSymbolPresence -> AdaSymbolPresence -> AdaSymbolPresence Source # min :: AdaSymbolPresence -> AdaSymbolPresence -> AdaSymbolPresence Source # |
newtype GenCurrencySymbol (p :: AdaSymbolPresence) Source #
A helper (opaque) newtype for QuickCheck use with CurrencySymbol
s. Has a
type-level tag to indicate whether or not it could potentially contain a
CurrencySymbol
. We provide instances of Arbitrary
, CoArbitrary
and
Function
around this newtype, intended to act on the CurrencySymbol
inside
it.
The easiest way to use this newtype is by pattern matching:
forAll arbitrary $ \(GenCurrencySymbol @WithAdaSymbol sym) -> ...
You can also 're-wrap' for shrinking:
shrink $ GenCurrencySymbol @WithAdaSymbol sym
However, as GenCurrencySymbol
instances do not shrink, there's not much point.
Since: 2.1.3
Instances
Arbitrary (GenCurrencySymbol 'WithAdaSymbol) Source # | This instance occasionally has the ability to produce the ADA symbol (that
is, the empty \[ frac{1}{2^{8 \cdot 28 = 224} + 1} \] However, in this case, the odds are actually \[ \frac{1}{2^{62} + 1} \] This is a limitation of probability distributions as implemented by
QuickCheck, which uses This instance does not shrink, as it makes very little sense to. Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers | |
Arbitrary (GenCurrencySymbol 'WithoutAdaSymbol) Source # | This instance never produces the ADA symbol. Like the corresponding
Since: 2.1.3 |
CoArbitrary (GenCurrencySymbol p) Source # | Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers coarbitrary :: GenCurrencySymbol p -> Gen b -> Gen b Source # | |
Function (GenCurrencySymbol p) Source # | Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers function :: (GenCurrencySymbol p -> b) -> GenCurrencySymbol p :-> b Source # | |
Show (GenCurrencySymbol p) Source # | Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers | |
Eq (GenCurrencySymbol p) Source # | Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers (==) :: GenCurrencySymbol p -> GenCurrencySymbol p -> Bool Source # (/=) :: GenCurrencySymbol p -> GenCurrencySymbol p -> Bool Source # |
newtype GenValue (adaMod :: Type -> Type) (otherMod :: Type -> Type) Source #
A helper (opaque) newtype for QuickCheck use with Value
s. Has two type
arguments, to indicate, in order, what kind of amounts ADA and non-ADA
entries are allowed to have.
The Value
s wrapped inside this type are phase-1 valid; the only validity we
can't guarantee is to do with amounts, as these depend on choice of
modifiers.
The easiest way to use this newtype is by pattern matching:
forAll arbitrary $ \(GenValue @NonNegative @Positive val) -> ...
In this case, the ADA entry in val
would contain a non-negative amount, but
any other entry would contain a strictly positive one.
You can also 're-wrap' for shrinking:
shrink $ GenValue @NonNegative @Positive val
Note
As GenValue
relies heavily on Coercible
to work, the newtype constructors
of your modifiers need to be in scope, or you will get strange errors. For
example, if you want to do
GenValue @NonNegative @Positive val <- arbitrary
you must have both the NonNegative
and Positive
types, as well as their
newtype constructors, imported.
Since: 2.1.3
Instances
(Arbitrary (adaMod Integer), Arbitrary (otherMod Integer), forall a. Coercible (adaMod a) a, forall a. Coercible (otherMod a) a) => Arbitrary (GenValue adaMod otherMod) Source # | This instance ensures phase-1 validity up to amounts. Specifically, the following are guaranteed to hold irrespective of 'tag choices':
The kind of amount generated for ADA and non-ADA entries is controlled by the
two tags: the first determines how the ADA amount will get generated, while
the second determines how any non-ADA amounts get generated. Thus,
In order to ensure all invariants hold, the shrinker for
More specifically, neither Since: 2.1.3 |
CoArbitrary (GenValue adaMod otherMod) Source # | Since: 2.1.3 |
Defined in Plutarch.Test.QuickCheck.Modifiers | |
Function (GenValue adaMod otherMod) Source # | Since: 2.1.3 |
Show (GenValue adaMod otherMod) Source # | Since: 2.1.3 |
Eq (GenValue adaMod otherMod) Source # | Since: 2.1.3 |
data TimeDelta (mod :: Type -> Type) (n :: Nat) Source #
Represents a change in POSIXTime
. The mod
argument gives the kind of
change, represented by a QuickCheck modifier, while the n
argument is a
closed (inclusive) upper bound on the magnitude of the change.
For example,
represents a change in TimeDelta
Positive
100POSIXTime
from 1
to 100
units, while
represents a
change in TimeDelta
NonPositive
250POSIXTime
from 0
to -250
. Modifiers intended to work with
this type are:
The instances for TimeDelta
reflect this decision: while other modifiers
could potentially be useful, this ensures that we have safe behaviour and
efficient instances.
NonZero
is treated a bit specially in that the magnitude indicated by n
is in both the negative and positive direction. Thus,
spans the union of TimeDelta
NonZero
50[-50, -1]
and [1, 50]
.
Shrinking a TimeDelta
will shrink towards zero: more specifically, it will
reduce the magnitude of the change.
To control what TimeDelta
you get, the easiest method is a type signature:
forAll arbitrary $ \(delta :: TimeDelta NonNegative 100) -> ...
Since: 2.1.4
Instances
Functions
timeDeltaProperty :: forall (n :: Nat) (mod :: Type -> Type). Coercible (mod POSIXTime) Integer => (POSIXTime -> Property) -> POSIXTime -> TimeDelta mod n -> Property Source #
A CPS-style Property
handler for applying a TimeDelta
to a POSIXTime
.
If the application of the delta to the time would produce an impossible
result (that is, the resulting time is negative), this will automatically
fail the property test with an informative message; otherwise, it will apply
the delta, and produce a new POSIXTime
, which it will pass to the function
argument to determine the outcome.
The arguments are ordered to conveniently use with forAll
and similar.
Since: 2.1.4