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

Evaluation.Builtins.Costing

Synopsis
  • eqCostStream :: CostStreams. Same as deriving stock Eq. We don't want to do the latter, because the semantics of a CostStream are those of the sum of its elements and the derived SatInt belongs. E.g.

    >>> toRange 42
    (11,100)
    >>> toRange 1234
    (1001,10000) 
    

chooseSatInt :: (addCostStream equals the sum of the sums of its two arguments.

test_minCostStreamIsMin :: minCostStream equals the minimum of the sums of its two arguments.

test_zipCostStreamIsZip :: ExBudget containing the sums of its two arguments.

test_mapCostStreamReasonableLength :: addCostStream equals the sum of the lengths of its two arguments.

test_minCostStreamReasonableLength :: zipCostStream equals the maximum of the lengths of its two arguments.

test_mapCostStreamHandlesBottom :: minCostStream preserves the laziness of its two arguments.

postAlignWith :: a -> [a] -> [a] -> ([a], [a]) #

Pad the shortest of the given lists by appending the given element to it until the length of the result matches the length of the other list.

>>> postAlignWith 'a' "bcd" "e"
("bcd","eaa")
>>> postAlignWith 'a' "b" "cdef"
("baaa","cdef") 

test_zipCostStreamHandlesBottom :: CostRose #

Return a finite balanced tree with each node (apart from the leaves) having exactly 3 children. The parameter is the depth of the tree. Named after https://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle

test_flattenCostRoseIsLinearForSierpinskiRose :: TestTree #

Traverse a sierpinskiRose of the given depth and display the total amount of elements processed. See test_flattenCostRoseIsLinear for why we do this.

test_flattenCostRoseIsLinear :: CostRose takes _linearly_ more time. The actual test can only be done with eyes unfortunately, because the tests are way too noisy for evaluation times to be reported even remotely accurately.

genCostRose :: CostRose from the given list by splitting the list into sublists and generating a memoryUsage called over a value of a built-in type never returns a stream containing a negative cost.

test_costing :: SatInts with exponentially lower chance. This is in order to make the generator of CostStream produce streams whose sums are more or less evenly distributed across magnitudes.

Instance details

Methods

arbitrary :: SatInt :-> b #

NonEmptyList a -> a #