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

PlutusIR.Generators.QuickCheck.GenerateTerms

Synopsis

Documentation

data TyInst #

This type keeps track of what kind of argument, term argument (InstArg) or type argument (InstApp) is required for a function. This type is used primarily with findInstantiation below where we do unification to figure out if we can use a variable to construct a term of a target type.

Constructors

InstApp (DefaultUni () -> Either String [TyInst] #

If successful `findInstantiation n target ty` for an `x :: ty` gives a sequence of TyInsts containing n InstArgs such that x instantiated (type application for InstApp and applied to a term of the given type for InstArg) at the TyInstss has type target

genConstant :: DefaultFun ()) #

Try to inhabit a given type in as simple a way as possible, prefers to not default to DefaultFun ()) #

Generate a term, if the first argument is Nothing then we get something of any type and if the first argument is `Just ty` we get something of type ty.

Requires the type to be of kind *.

scaledListOf :: GenTm a -> GenTm [a] #

Like listOf except each of the elements is generated with a proportionally smaller size.

genDatatypeLet :: DefaultUni ()] -> GenTm a) -> GenTm a #

Generate up to 5 datatypes and bind them in a generator. NOTE: despite its name this function does in fact not generate the Let binding for the datatypes.

genTypeAndTerm_ :: Gen (DefaultFun ()) #

Take a term of a specified type and generate a fully applied term. Useful for generating terms that you want to stick directly in an interpreter. Prefers to generate small arguments. NOTE: The logic of this generating small arguments is that the inner term should already have plenty of complicated arguments to functions to begin with and now we just want to fill out the arguments so that we get something that hopefully evaluates for a non-trivial number of steps.

genTermInContext_ :: TypeCtx -> DefaultFun ()) #

Generate a term of a specific type given a type and term context