Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Evaluation.Builtins.Costing
Contents
Synopsis
- eqCostStream ∷ CostStream → CostStream → Bool
- fromCostList ∷ NonEmptyList CostingInteger → CostStream
- toCostList ∷ CostStream → NonEmptyList CostingInteger
- toExBudgetList ∷ ExBudgetStream → NonEmptyList ExBudget
- magnitudes ∷ [(SatInt, SatInt)]
- toRange ∷ SatInt → (SatInt, SatInt)
- chooseSatInt ∷ (SatInt, SatInt) → Gen SatInt
- checkEqualsVia ∷ Show a ⇒ (a → a → Bool) → a → a → Property
- bottom ∷ a
- test_magnitudes ∷ TestTree
- test_CostStreamDistribution ∷ TestTree
- test_toCostListRoundtrip ∷ TestTree
- test_fromCostListRoundtrip ∷ TestTree
- test_unconsCostRoundtrip ∷ TestTree
- test_sumCostStreamIsSum ∷ TestTree
- test_mapCostStreamIsMap ∷ TestTree
- test_addCostStreamIsAdd ∷ TestTree
- test_minCostStreamIsMin ∷ TestTree
- test_zipCostStreamIsZip ∷ TestTree
- test_mapCostStreamReasonableLength ∷ TestTree
- test_addCostStreamReasonableLength ∷ TestTree
- test_minCostStreamReasonableLength ∷ TestTree
- test_zipCostStreamReasonableLength ∷ TestTree
- test_mapCostStreamHandlesBottom ∷ TestTree
- test_addCostStreamHandlesBottom ∷ TestTree
- test_minCostStreamHandlesBottom ∷ TestTree
- postAlignWith ∷ a → [a] → [a] → ([a], [a])
- test_zipCostStreamHandlesBottom ∷ TestTree
- sierpinskiSize ∷ Int → Int
- sierpinskiRose ∷ Int → CostRose
- test_flattenCostRoseIsLinearForSierpinskiRose ∷ Int → TestTree
- test_flattenCostRoseIsLinear ∷ TestTree
- genCostRose ∷ NonEmptyList SatInt → Gen CostRose
- fromCostRose ∷ CostRose → NonEmptyList SatInt
- collectListLengths ∷ CostRose → [Int]
- test_CostRoseListLengthsDistribution ∷ TestTree
- test_genCostRoseSound ∷ TestTree
- test_flattenCostRoseSound ∷ TestTree
- test_flattenCostRoseHandlesBottom ∷ TestTree
- test_costsAreNeverNegative ∷ TestTree
- test_costing ∷ TestTree
Documentation
eqCostStream ∷ CostStream → CostStream → Bool Source #
Direct equality of two CostStream
s. 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)]
.
toRange ∷ SatInt → (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)
checkEqualsVia ∷ Show a ⇒ (a → a → Bool) → a → a → Property Source #
Same as (===)
except accepts a custom equality checking function.
A value to use in tests to make sure what's not supposed to be forced isn't forced.
test_magnitudes ∷ TestTree Source #
Test that magnitudes
has the correct bounds.
test_CostStreamDistribution ∷ TestTree Source #
Show the distribution of generated CostStream
s as a diagnostic.
test_toCostListRoundtrip ∷ TestTree Source #
Test that fromCostList . toCostList
is identity.
test_fromCostListRoundtrip ∷ TestTree Source #
Test that toCostList . fromCostList
is identity.
test_unconsCostRoundtrip ∷ TestTree Source #
Test that uncurry reconsCost . unconsCost
is identity.
test_sumCostStreamIsSum ∷ TestTree Source #
Test that sumCostStream
returns the sum of the elements of a CostStream
.
test_mapCostStreamIsMap ∷ TestTree Source #
Test that mapCostStream
applies a function to each element of a CostStream
.
test_addCostStreamIsAdd ∷ TestTree Source #
Test that the sum of a stream returned by addCostStream
equals the sum of the sums of its two
arguments.
test_minCostStreamIsMin ∷ TestTree Source #
Test that the sum of a stream returned by minCostStream
equals the minimum of the sums of its
two arguments.
test_zipCostStreamIsZip ∷ TestTree Source #
Test that the sum of a stream returned by zipCostStream
equals an ExBudget
containing the
sums of its two arguments.
test_mapCostStreamReasonableLength ∷ TestTree Source #
Test that mapCostStream
preserves the length of the stream.
test_addCostStreamReasonableLength ∷ TestTree Source #
Test that the length of the stream returned by addCostStream
equals the sum of the lengths of
its two arguments.
test_minCostStreamReasonableLength ∷ TestTree Source #
Test that the length of the stream returned by addCostStream
is
- greater than or equal to the minimum of the lengths of its two arguments
- smaller than or equal to the sum of the lengths of its two arguments.
test_zipCostStreamReasonableLength ∷ TestTree Source #
Test that the length of the stream returned by zipCostStream
equals the maximum of the
lengths of its two arguments.
test_mapCostStreamHandlesBottom ∷ TestTree Source #
Test that mapCostStream
preserves the laziness of its argument.
test_addCostStreamHandlesBottom ∷ TestTree Source #
Test that mapCostStream
preserves the laziness of its two arguments.
test_minCostStreamHandlesBottom ∷ TestTree 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_zipCostStreamHandlesBottom ∷ TestTree Source #
Test that zipCostStream
preserves the laziness of its two arguments.
sierpinskiSize ∷ Int → Int Source #
The size sierpinskiRose
of the given depth.
sierpinskiRose ∷ Int → CostRose 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_flattenCostRoseIsLinearForSierpinskiRose ∷ Int → TestTree 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_flattenCostRoseIsLinear ∷ TestTree 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.
test_CostRoseListLengthsDistribution ∷ TestTree Source #
Show the distribution of forest lengths in generated CostRose
values as a diagnostic.
test_genCostRoseSound ∷ TestTree Source #
Test that genCostRose
only takes costs from its argument when generating a CostRose
.
test_flattenCostRoseSound ∷ TestTree Source #
Test that flattenCostRose
returns the elements of its argument.
test_flattenCostRoseHandlesBottom ∷ TestTree Source #
Test that flattenCostRose
is lazy.
test_costsAreNeverNegative ∷ TestTree Source #
Test that memoryUsage
called over a value of a built-in type never returns a stream
containing a negative cost.