plutus-core-1.54.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusCore.Generators.QuickCheck.Builtin

Synopsis

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.

Minimal complete definition

Nothing

Methods

arbitraryBuiltinGen a Source #

default arbitraryBuiltinArbitrary a ⇒ Gen a Source #

shrinkBuiltin ∷ a → [a] Source #

default shrinkBuiltinArbitrary a ⇒ a → [a] Source #

Instances

Instances details
ArbitraryBuiltin ByteString Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin Element Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin Element Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin MlResult Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin Data Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin Value Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin Text Source #
>>> shrinkBuiltin $ Text.pack "abcd"
["","cd","ab","bcd","acd","abd","abc","aacd","abad","abbd","abca","abcb","abcc"]
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin Integer Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin () Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

Methods

arbitraryBuiltinGen () Source #

shrinkBuiltin ∷ () → [()] Source #

ArbitraryBuiltin Bool Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin a ⇒ ArbitraryBuiltin (Vector a) Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

ArbitraryBuiltin a ⇒ ArbitraryBuiltin [a] Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

Methods

arbitraryBuiltinGen [a] Source #

shrinkBuiltin ∷ [a] → [[a]] Source #

(ArbitraryBuiltin a, ArbitraryBuiltin b) ⇒ ArbitraryBuiltin (a, b) Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

Methods

arbitraryBuiltinGen (a, b) Source #

shrinkBuiltin ∷ (a, b) → [(a, b)] Source #

magnitudesPositive ∷ (IntegerInteger) → 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 ∷ (IntegerInteger) → IntegerGen 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 ∷ (IntegerInteger) → IntegerGen Integer Source #

Same as arbitraryPositive except produces negative integers.

shrinkIntegralFastIntegral 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]

genConstrTagGen Integer Source #

Generate a tag for the Constr constructor.

genDataFromSpine ∷ [()] → Gen Data Source #

Generate a Data object using a spine :: [()] as a hint. It's helpful to make the spine a list of units rather than a Word or something, because we have useful functions for arbitrary list splitting.

pureIfNull ∷ (Foldable f, Applicative f) ⇒ a → f a → f a Source #

toCellCandidatesNumberIntInt Source #

Return how many candidates to randomly choose from to fill the given number of cells. For example, if we only need to fill a single cell, we choose from 6 different candidates, and if we need to fill 5 cells, we choose from 11 candidates.

>>> map (\i -> (i, toCellCandidatesNumber i)) [1..13]
[(1,6),(2,6),(3,6),(4,8),(5,11),(6,14),(7,18),(8,22),(9,27),(10,31),(11,36),(12,41),(13,46)]

genShortHexIntGen K Source #

Generate a ByteString by picking one of the predetermined ones, given a number of cells to fill (see toCellCandidatesNumber). The idea is that we want to occasionally generate the same CurrencySymbol or TokenName for different Values to have decent test coverage, hence to make name clashing more likely we pick from a predetermined set of ByteStrings. Otherwise the chance of generating the same ByteString for two different Values would be virtually zero.

uniqueNamesEq name ⇒ (K → name) → [b] → Gen [(name, b)] Source #

Annotate each element of the give list with a name, given a function turning ByteString into names.

newtype NoArbitrary a Source #

A wrapper for satisfying an Arbitrary a constraint without implementing an Arbitrary instance for a.

Constructors

NoArbitrary 

Fields

Instances

Instances details
Arbitrary (NoArbitrary a) Source #

arbitrary throws, shrink neither throws nor shrinks.

Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

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.

Constructors

AsArbitraryBuiltin 

Fields

Instances

Instances details
ArbitraryBuiltin a ⇒ Arbitrary (AsArbitraryBuiltin a) Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

Num a ⇒ Num (AsArbitraryBuiltin a) Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

Show a ⇒ Show (AsArbitraryBuiltin a) Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

Eq a ⇒ Eq (AsArbitraryBuiltin a) Source # 
Instance details

Defined in PlutusCore.Generators.QuickCheck.Builtin

Ord a ⇒ Ord (AsArbitraryBuiltin a) Source # 
Instance details

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.

Constructors

NothingSomeType 
∀ (a ∷ k). JustSomeType (DefaultUni (Esc a)) 

eraseMaybeSomeTypeOfMaybeSomeTypeOf k → Maybe (SomeTypeIn DefaultUni) Source #

Forget the reflected at the type level kind.

shrinkToStarArgsDefaultUni (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 *.

shrinkDropBuiltinSameKindDefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k] Source #

Shrink a built-in type while preserving its kind.

shrinkDefaultUniApplyDefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k] Source #

Shrink a function application by shrinking either the function or the argument. The kind is preserved.

shrinkBuiltinSameKindDefaultUni (Esc (a ∷ k)) → [MaybeSomeTypeOf k] Source #

Kind-preserving shrinking for DefaultUni.

genBuiltinTypeOfKind () → Gen (Maybe (SomeTypeIn DefaultUni)) Source #

Generate a built-in type of a given kind.

shrinkDropBuiltinDefaultUni (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.

shrinkBuiltinTypeSomeTypeIn DefaultUni → [SomeTypeIn DefaultUni] Source #

Non-kind-preserving shrinking for DefaultUni.

Orphan instances

Arbitrary Data Source # 
Instance details

Methods

arbitraryGen Data #

shrinkData → [Data] #

Arbitrary K Source # 
Instance details

Methods

arbitraryGen K #

shrinkK → [K] #

Arbitrary Value Source # 
Instance details

Methods

arbitraryGen Value #

shrinkValue → [Value] #

Arbitrary (SomeTypeIn DefaultUni) Source # 
Instance details

Arbitrary (Some (ValueOf DefaultUni)) Source # 
Instance details