plutus-core-1.39.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 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 [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 #

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

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