Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class ArbitraryBuiltin a where
- arbitraryBuiltin ∷ Gen a
- shrinkBuiltin ∷ a → [a]
- nextInterestingBound ∷ Integer → Integer
- highInterestingBound ∷ Integer
- magnitudesPositive ∷ (Integer → Integer) → Integer → [(Integer, Integer)]
- chooseIntegerPreferEnds ∷ (Integer, Integer) → Gen Integer
- arbitraryPositive ∷ (Integer → Integer) → Integer → Gen Integer
- arbitraryNegative ∷ (Integer → Integer) → Integer → Gen Integer
- arbitrarySigned ∷ (Integer → Integer) → Integer → Gen Integer
- shrinkIntegralFast ∷ Integral a ⇒ a → [a]
- genConstrTag ∷ Gen Integer
- genDataFromSpine ∷ [()] → Gen Data
- pureIfNull ∷ (Foldable f, Applicative f) ⇒ a → f a → f a
- newtype AsArbitraryBuiltin a = AsArbitraryBuiltin {}
- data MaybeSomeTypeOf k
- = NothingSomeType
- | ∀ (a ∷ k). JustSomeType (DefaultUni (Esc a))
- eraseMaybeSomeTypeOf ∷ MaybeSomeTypeOf k → Maybe (SomeTypeIn DefaultUni)
- genDefaultUniApply ∷ KnownKind k ⇒ Gen (MaybeSomeTypeOf k)
- shrinkToStarArgs ∷ DefaultUni (Esc a) → [MaybeSomeTypeOf Type]
- shrinkDropBuiltinSameKind ∷ DefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k]
- shrinkDefaultUniApply ∷ DefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k]
- shrinkBuiltinSameKind ∷ DefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k]
- genBuiltinTypeOf ∷ Kind () → Gen (Maybe (SomeTypeIn DefaultUni))
- shrinkDropBuiltin ∷ DefaultUni (Esc (a ∷ k)) → [SomeTypeIn DefaultUni]
- shrinkBuiltinType ∷ SomeTypeIn DefaultUni → [SomeTypeIn DefaultUni]
Documentation
class ArbitraryBuiltin a where Source #
Same as Arbitrary
but specifically for Plutus built-in types, so that we are not tied to
the default implementation of the methods for a built-in type.
Nothing
arbitraryBuiltin ∷ Gen a Source #
default arbitraryBuiltin ∷ Arbitrary a ⇒ Gen a Source #
shrinkBuiltin ∷ a → [a] Source #
default shrinkBuiltin ∷ Arbitrary a ⇒ a → [a] Source #
Instances
magnitudesPositive ∷ (Integer → Integer) → Integer → [(Integer, Integer)] Source #
A list of ranges.
>>>
import Data.Int
>>>
magnitudesPositive (* 10) (toInteger (maxBound :: Int16))
[(1,10),(11,100),(101,1000),(1001,10000),(10001,32767)]>>>
magnitudesPositive nextInterestingBound (toInteger (maxBound :: Int64))
[(1,127),(128,32767),(32768,2147483647),(2147483648,9223372036854775807)]
arbitraryPositive ∷ (Integer → Integer) → Integer → Gen Integer Source #
Generate asymptotically larger positive negative numbers (sans zero) with exponentially lower chance, stop at the geometric mean of the range and start increasing the probability of generating larger numbers, so that we generate we're most likely to generate numbers that are either fairly small or really big. Numbers at the beginning of the range are more likely to get generated than at the very end, but only by a fairly small factor. The size parameter is ignored, which is perhaps wrong and should be fixed.
arbitraryNegative ∷ (Integer → Integer) → Integer → Gen Integer Source #
Same as arbitraryPositive
except produces negative integers.
shrinkIntegralFast ∷ Integral a ⇒ a → [a] Source #
Same as shrinkIntegral
except includes the square root of the given number (or of its
negative if the number is negative, in which case the square root is negated too). We need the
former because shrinkIntegral
at most divides the number by two, which makes the number smaller
way too slow, hence we add square root to speed up the process.
>>>
shrinkIntegralFast (0 :: Integer)
[]>>>
shrinkIntegralFast (1 :: Integer)
[0]>>>
shrinkIntegralFast (9 :: Integer)
[0,3,5,7,8]>>>
shrinkIntegralFast (-10000 :: Integer)
[0,10000,-100,-5000,-7500,-8750,-9375,-9688,-9844,-9922,-9961,-9981,-9991,-9996,-9998,-9999]
genDataFromSpine ∷ [()] → Gen Data Source #
pureIfNull ∷ (Foldable f, Applicative f) ⇒ a → f a → f a Source #
newtype AsArbitraryBuiltin a Source #
For providing an Arbitrary
instance deferring to ArbitraryBuiltin
. Useful for implementing
ArbitraryBuiltin
for a polymorphic built-in type by taking the logic for handling spines from
the Arbitrary
class and the logic for handling elements from ArbitraryBuiltin
.
Instances
ArbitraryBuiltin a ⇒ Arbitrary (AsArbitraryBuiltin a) Source # | |
Defined in PlutusCore.Generators.QuickCheck.Builtin arbitrary ∷ Gen (AsArbitraryBuiltin a) Source # shrink ∷ AsArbitraryBuiltin a → [AsArbitraryBuiltin a] Source # | |
Show a ⇒ Show (AsArbitraryBuiltin a) Source # | |
Defined in PlutusCore.Generators.QuickCheck.Builtin |
data MaybeSomeTypeOf k Source #
Either a fail to generate anything or a built-in type of a given kind.
NothingSomeType | |
∀ (a ∷ k). JustSomeType (DefaultUni (Esc a)) |
Instances
KnownKind k ⇒ Arbitrary (MaybeSomeTypeOf k) Source # | |
Defined in PlutusCore.Generators.QuickCheck.Builtin arbitrary ∷ Gen (MaybeSomeTypeOf k) Source # shrink ∷ MaybeSomeTypeOf k → [MaybeSomeTypeOf k] Source # | |
Eq (MaybeSomeTypeOf k) Source # | |
Defined in PlutusCore.Generators.QuickCheck.Builtin (==) ∷ MaybeSomeTypeOf k → MaybeSomeTypeOf k → Bool Source # (/=) ∷ MaybeSomeTypeOf k → MaybeSomeTypeOf k → Bool Source # |
eraseMaybeSomeTypeOf ∷ MaybeSomeTypeOf k → Maybe (SomeTypeIn DefaultUni) Source #
Forget the reflected at the type level kind.
genDefaultUniApply ∷ KnownKind k ⇒ Gen (MaybeSomeTypeOf k) Source #
Generate a DefaultUniApply
if possible.
shrinkToStarArgs ∷ DefaultUni (Esc a) → [MaybeSomeTypeOf Type] Source #
Shrink a DefaultUniApply
to one of the elements of the spine and throw away the head
(because the head of an application can't be of the same kind as the whole application).
We don't have higher-kinded built-in types, so we don't do this kind of shrinking for any kinds
other than *.
shrinkDropBuiltinSameKind ∷ DefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k] Source #
Shrink a built-in type while preserving its kind.
shrinkDefaultUniApply ∷ DefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k] Source #
Shrink a function application by shrinking either the function or the argument. The kind is preserved.
shrinkBuiltinSameKind ∷ DefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k] Source #
Kind-preserving shrinking for DefaultUni
.
genBuiltinTypeOf ∷ Kind () → Gen (Maybe (SomeTypeIn DefaultUni)) Source #
Generate a built-in type of a given kind.
shrinkDropBuiltin ∷ DefaultUni (Esc (a ∷ k)) → [SomeTypeIn DefaultUni] Source #
Shrink a built-in type by dropping a part of it or dropping the whole built-in type in favor of
a some minimal one (see shrinkDropBuiltinSameKind
). The kind is not preserved in the general
case.
shrinkBuiltinType ∷ SomeTypeIn DefaultUni → [SomeTypeIn DefaultUni] Source #
Non-kind-preserving shrinking for DefaultUni
.