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

PlutusCore.Evaluation.Machine.CostStream

Synopsis

Documentation

data CostStream Source #

A lazy stream of CostingIntegers. Basically NonEmpty CostingInteger, except the elements are stored strictly.

The semantics of a stream are those of the sum of its elements. I.e. a stream that is a reordered version of another stream is considered equal to that stream.

All costs are assumed not to be negative and functions handling CostStreams may rely on this assumption. Negative costs (a.k.a. allowing the user to forge execution units at runtime) wouldn't make sense.

Instances

Instances details
Show CostStream Source # 
Instance details

Defined in PlutusCore.Evaluation.Machine.CostStream

unconsCostCostStream → (CostingInteger, Maybe CostStream) Source #

Uncons an element from a CostStream and return the rest of the stream, if not empty.

reconsCostCostingIntegerMaybe CostStreamCostStream Source #

Cons an element to a CostStream, if given any. Otherwise create a new CostStream using CostLast.

sumCostStreamCostStreamCostingInteger Source #

Add up all the costs in a CostStream.

addCostStreamCostStreamCostStreamCostStream Source #

Add two streams by interleaving their elements (as opposed to draining out one of the streams before starting to take elements from the other one). No particular reason to prefer interleaving over draining out one of the streams first.

minCostStreamCostStreamCostStreamCostStream Source #

Calculate the minimum of two CostStreams. May return a stream that is longer than either of the two (but not more than twice).