Commit c903c846 authored by Niklas Hambuechen's avatar Niklas Hambuechen
Browse files

SlotMap: Clarify adding to empty SlotMap

This points out an important case when `hasSlotsFor` returns False.
Signed-off-by: default avatarNiklas Hambuechen <>
Reviewed-by: default avatarKlaus Aehlig <>
parent bcf6c4aa
......@@ -93,6 +93,9 @@ occupySlots sm counts = Map.unionWith
-- The `SlotMap` is allowed to be overfull in some keys; this function
-- still returns True as long as as adding the counts to the `SlotMap` would
-- not *create or increase* overfull keys.
-- Adding counts > 0 for a key which is not in the `SlotMap` does create
-- overfull keys.
hasSlotsFor :: (Ord a) => SlotMap a -> CountMap a -> Bool
slotMap `hasSlotsFor` counts =
let relevantSlots = slotMap `Map.intersection` counts
......@@ -217,6 +217,9 @@ case_hasSlotsFor_examples = do
assertBool "empty not fitting"
. not $ Map.empty `hasSlotsFor` Map.fromList [("a", 1), ("b", 100)]
assertBool "empty not fitting"
. not $ Map.empty `hasSlotsFor` Map.fromList [("a", 1)]
-- | Tests properties of `hasSlotsFor` on `SlotMap`s that are known to
-- respect their limits.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment