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

PlutusCore.Generators.Hedgehog.Interesting

Description

Sample generators used for tests.

Synopsis

Documentation

type TermGen a = Gen (TermWith (Term TyName Name DefaultUni DefaultFun ()) a) Source #

The type of terms-and-their-values generators.

data TermWith term a Source #

A term along with the corresponding Haskell value.

Constructors

TermWith 

Fields

Instances

Instances details
(PrettyBy config a, PrettyBy config term) ⇒ PrettyBy config (TermWith term a) Source # 
Instance details

Defined in PlutusCore.Generators.Hedgehog.TypedBuiltinGen

Methods

prettyBy ∷ config → TermWith term a → Doc ann Source #

prettyListBy ∷ config → [TermWith term a] → Doc ann Source #

Foldable (TermWith term) Source # 
Instance details

Defined in PlutusCore.Generators.Hedgehog.TypedBuiltinGen

Methods

foldMonoid m ⇒ TermWith term m → m Source #

foldMapMonoid m ⇒ (a → m) → TermWith term a → m Source #

foldMap'Monoid m ⇒ (a → m) → TermWith term a → m Source #

foldr ∷ (a → b → b) → b → TermWith term a → b Source #

foldr' ∷ (a → b → b) → b → TermWith term a → b Source #

foldl ∷ (b → a → b) → b → TermWith term a → b Source #

foldl' ∷ (b → a → b) → b → TermWith term a → b Source #

foldr1 ∷ (a → a → a) → TermWith term a → a Source #

foldl1 ∷ (a → a → a) → TermWith term a → a Source #

toListTermWith term a → [a] Source #

nullTermWith term a → Bool Source #

lengthTermWith term a → Int Source #

elemEq a ⇒ a → TermWith term a → Bool Source #

maximumOrd a ⇒ TermWith term a → a Source #

minimumOrd a ⇒ TermWith term a → a Source #

sumNum a ⇒ TermWith term a → a Source #

productNum a ⇒ TermWith term a → a Source #

Traversable (TermWith term) Source # 
Instance details

Defined in PlutusCore.Generators.Hedgehog.TypedBuiltinGen

Methods

traverseApplicative f ⇒ (a → f b) → TermWith term a → f (TermWith term b) Source #

sequenceAApplicative f ⇒ TermWith term (f a) → f (TermWith term a) Source #

mapMMonad m ⇒ (a → m b) → TermWith term a → m (TermWith term b) Source #

sequenceMonad m ⇒ TermWith term (m a) → m (TermWith term a) Source #

Functor (TermWith term) Source # 
Instance details

Defined in PlutusCore.Generators.Hedgehog.TypedBuiltinGen

Methods

fmap ∷ (a → b) → TermWith term a → TermWith term b Source #

(<$) ∷ a → TermWith term b → TermWith term a Source #

genOverapplicationTermGen Integer Source #

Generates application of a builtin that returns a function, immediately saturated afterwards.

ifThenElse {integer -> integer -> integer} (lessThanInteger i j) addInteger subtractInteger i j
    == if i < j then i + j else i - j 

factorialTerm TyName Name DefaultUni DefaultFun () Source #

i -> product [1 :: Integer .. i] as a PLC term.

\(i : integer) -> product (enumFromTo 1 i) 

genFactorialTermGen Integer Source #

Generate a term that computes the factorial of an integer and return it along with the factorial of the corresponding Integer computed on the Haskell side.

naiveFibIntegerTerm TyName Name DefaultUni DefaultFun () Source #

The naive exponential fibonacci function as a PLC term.

\(i0 : integer) ->
    fix {integer} {integer}
        (\(rec : integer -> integer) (i : integer) ->
                ifThenElse {integer}
                    (lessThanEqInteger i 1)
                    (\(u : unit) -> i)
                    (\(u : unit) -> addInteger
                        (rec (subtractInteger i 1))
                        (rec (subtractInteger i 2)))
        i0 

genNaiveFibTermGen Integer Source #

Generate a term that computes the ith Fibonacci number and return it along with the corresponding Integer computed on the Haskell side.

genNatRoundtripTermGen Integer Source #

Generate an Integer, turn it into a Scott-encoded PLC Nat (see Nat), turn that Nat into the corresponding PLC integer using a fold (see FoldNat) defined in terms of generic fix (see Fix) and return the result along with the original Integer

natSumTerm TyName Name DefaultUni DefaultFun () Source #

sumNat as a PLC term.

genScottListSumTermGen Integer Source #

Generate a list of Integers, turn it into a Scott-encoded PLC List (see List), sum elements of the list (see Sum) and return it along with the sum of the original list.

genIfIntegersTermGen Integer Source #

Generate a boolean and two integers and check whether if b then i1 else i2 means the same thing in Haskell and PLC. Terms are generated using genTermLoose.

fromInterestingTermGens ∷ (∀ a. KnownType (Term TyName Name DefaultUni DefaultFun ()) a ⇒ StringTermGen a → c) → [c] Source #

Apply a function to all interesting generators and collect the results.