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

PlutusIR.Generators.QuickCheck.GenerateTerms

Synopsis

Documentation

data TyInst Source #

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.

Instances

Instances details
Show TyInst Source # 
Instance details

Defined in PlutusIR.Generators.QuickCheck.GenerateTerms

PrettyBy config (Type TyName DefaultUni ()) ⇒ PrettyBy config TyInst Source # 
Instance details

Defined in PlutusIR.Generators.QuickCheck.GenerateTerms

Methods

prettyBy ∷ config → TyInstDoc ann Source #

prettyListBy ∷ config → [TyInst] → Doc ann Source #

findInstantiationHasCallStackTypeCtxIntType TyName DefaultUni () → Type TyName DefaultUni () → Either String [TyInst] Source #

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

inhabitTypeType TyName DefaultUni () → GenTm (Term TyName Name DefaultUni DefaultFun ()) Source #

Try to inhabit a given type in as simple a way as possible, prefers to not default to error

typeArityNum a ⇒ Type tyname uni ann → a Source #

genAtomicTermType TyName DefaultUni () → GenTm (Term TyName Name DefaultUni DefaultFun ()) Source #

Generate as small a term as possible to match a given type.

genTermOfTypeType TyName DefaultUni () → GenTm (Term TyName Name DefaultUni DefaultFun ()) Source #

Generate a term of a given type.

Requires the type to be of kind *.

genTermMaybe (Type TyName DefaultUni ()) → GenTm (Type TyName DefaultUni (), Term TyName Name DefaultUni DefaultFun ()) Source #

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

scaledListOfGenTm a → GenTm [a] Source #

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

genDatatypeLets ∷ ([Datatype TyName Name DefaultUni ()] → GenTm a) → GenTm a Source #

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.

genFullyAppliedType TyName DefaultUni () → Term TyName Name DefaultUni DefaultFun () → Gen (Type TyName DefaultUni (), Term TyName Name DefaultUni DefaultFun ()) Source #

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_TypeCtxMap Name (Type TyName DefaultUni ()) → Type TyName DefaultUni () → Gen (Term TyName Name DefaultUni DefaultFun ()) Source #

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