plutus-core-1.30.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

Methods

arbitraryBuiltinGen ByteString Source #

shrinkBuiltin ∷ ByteString → [ByteString] Source #

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

Methods

arbitraryBuiltinGen Text Source #

shrinkBuiltin ∷ Text → [Text] Source #

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 #

magnitudesPositiveIntegral a ⇒ a → a → [(a, a)] Source #

A list of ranges: [(0, 10), (11, 100), (101, 1000), ... (10^n + 1, high)] when base = 10.

chooseIntegralIntegral a ⇒ (a, a) → Gen a Source #

Like chooseBoundedIntegral, but doesn't require the Bounded constraint (and hence is slower for Word64 and Int64).

arbitraryPositiveIntegral a ⇒ a → a → Gen a Source #

Generate asymptotically greater positive numbers with exponentially lower chance.

arbitraryNegativeIntegral a ⇒ a → a → Gen a Source #

Generate asymptotically greater negative numbers with exponentially lower chance.

arbitrarySignedIntegral a ⇒ a → a → Gen a Source #

Generate asymptotically greater numbers with exponentially lower chance.

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

Arbitrary Data Source # 
Instance details

Methods

arbitraryGen Data #

shrinkData → [Data] #

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