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

unconsCost :: CostStream -> (CostingInteger, Maybe CostStream) Source #

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

reconsCost :: CostingInteger -> Maybe CostStream -> CostStream Source #

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

sumCostStream :: CostStream -> CostingInteger Source #

Add up all the costs in a CostStream.

addCostStream :: CostStream -> CostStream -> CostStream 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.

minCostStream :: CostStream -> CostStream -> CostStream Source #

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