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

Evaluation.Builtins.Costing

Synopsis

Documentation

eqCostStreamCostStreamCostStreamBool Source #

Direct equality of two 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 Eq instance would conflict with that.

magnitudes ∷ [(SatInt, SatInt)] Source #

A list of ranges: (0, 0), (1, 10) : (11, 100) : (101, 1000) : ... : [(10^18, maxBound)].

toRangeSatInt → (SatInt, SatInt) Source #

Return the range (in the sense of magnitudes) in which the given SatInt belongs. E.g.

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

chooseSatInt ∷ (SatInt, SatInt) → Gen SatInt Source #

Generate a SatInt in the given range.

checkEqualsViaShow a ⇒ (a → a → Bool) → a → a → Property Source #

Same as (===) except accepts a custom equality checking function.

bottom ∷ a Source #

A value to use in tests to make sure what's not supposed to be forced isn't forced.

test_magnitudesTestTree Source #

Test that magnitudes has the correct bounds.

test_CostStreamDistributionTestTree Source #

Show the distribution of generated CostStreams as a diagnostic.

test_toCostListRoundtripTestTree Source #

Test that fromCostList . toCostList is identity.

test_fromCostListRoundtripTestTree Source #

Test that toCostList . fromCostList is identity.

test_unconsCostRoundtripTestTree Source #

Test that uncurry reconsCost . unconsCost is identity.

test_sumCostStreamIsSumTestTree Source #

Test that sumCostStream returns the sum of the elements of a CostStream.

test_mapCostStreamIsMapTestTree Source #

Test that mapCostStream applies a function to each element of a CostStream.

test_addCostStreamIsAddTestTree Source #

Test that the sum of a stream returned by addCostStream equals the sum of the sums of its two arguments.

test_minCostStreamIsMinTestTree Source #

Test that the sum of a stream returned by minCostStream equals the minimum of the sums of its two arguments.

test_zipCostStreamIsZipTestTree Source #

Test that the sum of a stream returned by zipCostStream equals an ExBudget containing the sums of its two arguments.

test_mapCostStreamReasonableLengthTestTree Source #

Test that mapCostStream preserves the length of the stream.

test_addCostStreamReasonableLengthTestTree Source #

Test that the length of the stream returned by addCostStream equals the sum of the lengths of its two arguments.

test_minCostStreamReasonableLengthTestTree Source #

Test that the length of the stream returned by addCostStream is

  1. greater than or equal to the minimum of the lengths of its two arguments
  2. smaller than or equal to the sum of the lengths of its two arguments.

test_zipCostStreamReasonableLengthTestTree Source #

Test that the length of the stream returned by zipCostStream equals the maximum of the lengths of its two arguments.

test_mapCostStreamHandlesBottomTestTree Source #

Test that mapCostStream preserves the laziness of its argument.

test_addCostStreamHandlesBottomTestTree Source #

Test that mapCostStream preserves the laziness of its two arguments.

test_minCostStreamHandlesBottomTestTree Source #

Test that minCostStream preserves the laziness of its two arguments.

postAlignWith ∷ a → [a] → [a] → ([a], [a]) Source #

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_zipCostStreamHandlesBottomTestTree Source #

Test that zipCostStream preserves the laziness of its two arguments.

sierpinskiSizeIntInt Source #

The size sierpinskiRose of the given depth.

sierpinskiRoseIntCostRose Source #

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_flattenCostRoseIsLinearForSierpinskiRoseIntTestTree Source #

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

test_flattenCostRoseIsLinearTestTree Source #

Test that traversing a larger 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.

genCostRoseNonEmptyList SatIntGen CostRose Source #

Generate a CostRose from the given list by splitting the list into sublists and generating a CostRose for each of them recursively.

collectListLengthsCostRose → [Int] Source #

Return the lengths of all the forests in a CostRose.

test_CostRoseListLengthsDistributionTestTree Source #

Show the distribution of forest lengths in generated CostRose values as a diagnostic.

test_genCostRoseSoundTestTree Source #

Test that genCostRose only takes costs from its argument when generating a CostRose.

test_flattenCostRoseSoundTestTree Source #

Test that flattenCostRose returns the elements of its argument.

test_costsAreNeverNegativeTestTree Source #

Test that memoryUsage called over a value of a built-in type never returns a stream containing a negative cost.

Orphan instances

Arbitrary CostStream Source # 
Instance details

Arbitrary CostRose Source # 
Instance details

Arbitrary SatInt Source #

Generate asymptotically bigger 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

arbitraryGen SatInt #

shrinkSatInt → [SatInt] #

CoArbitrary SatInt Source # 
Instance details

Methods

coarbitrarySatIntGen b → Gen b #

Function SatInt Source # 
Instance details

Methods

function ∷ (SatInt → b) → SatInt :-> b #

Foldable NonEmptyList Source # 
Instance details

Methods

foldMonoid m ⇒ NonEmptyList m → m Source #

foldMapMonoid m ⇒ (a → m) → NonEmptyList a → m Source #

foldMap'Monoid m ⇒ (a → m) → NonEmptyList a → m Source #

foldr ∷ (a → b → b) → b → NonEmptyList a → b Source #

foldr' ∷ (a → b → b) → b → NonEmptyList a → b Source #

foldl ∷ (b → a → b) → b → NonEmptyList a → b Source #

foldl' ∷ (b → a → b) → b → NonEmptyList a → b Source #

foldr1 ∷ (a → a → a) → NonEmptyList a → a Source #

foldl1 ∷ (a → a → a) → NonEmptyList a → a Source #

toListNonEmptyList a → [a] Source #

nullNonEmptyList a → Bool Source #

lengthNonEmptyList a → Int Source #

elemEq a ⇒ a → NonEmptyList a → Bool Source #

maximumOrd a ⇒ NonEmptyList a → a Source #

minimumOrd a ⇒ NonEmptyList a → a Source #

sumNum a ⇒ NonEmptyList a → a Source #

productNum a ⇒ NonEmptyList a → a Source #