packages feed

range-set-list 0.0.6 → 0.0.7

raw patch · 5 files changed

+54/−15 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.RangeSet.List: findMax :: RSet a -> a
+ Data.RangeSet.List: findMin :: RSet a -> a

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+### 0.0.7++- `findMin` & `findMax`+ ### 0.0.6  - `size`
README.md view
@@ -30,9 +30,3 @@  and there aren't elements in between (not true for `Float` and `Double`). Also `succ` and `pred` are never called for largest or smallest value respectively.--## Changelog--- 0.0.3 Bump tasty and QuickCheck versions-- 0.0.2 More properties & test coverage-- 0.0.1 Initial release
range-set-list.cabal view
@@ -1,5 +1,5 @@ name:                range-set-list-version:             0.0.6+version:             0.0.7 synopsis:            Memory efficient sets with continuous ranges of elements. description:         Memory efficient sets with continuous ranges of elements. List based implementation. Interface mimics "Data.Set" interface where possible. homepage:            https://github.com/phadej/range-set-list
src/Data/RangeSet/List.hs view
@@ -58,6 +58,10 @@   , difference   , intersection +  -- * Min/Max+  , findMin+  , findMax+   -- * Complement   , complement @@ -204,6 +208,20 @@ -- | /O(n)/. Complement of the set. complement :: (Ord a, Enum a, Bounded a) => RSet a -> RSet a complement a = full `difference` a++{- Min/Max -}++-- | /O(1)/. The minimal element of a set.+findMin :: RSet a -> a+findMin (RSet ((x, _) : _))  = x+findMin _                    = error "RangeSet.List.findMin: empty set"++-- | /O(n)/. The minimal element of a set.+findMax :: RSet a -> a+findMax (RSet rs) = findMax' rs+  where findMax' [(_, x)]  = x+        findMax' (_:xs)    = findMax' xs+        findMax' _         = error "RangeSet.List.findMax: empty set"  {- Conversion -} 
tests/Tests.hs view
@@ -150,9 +150,31 @@   ]   where rs = rangeToRSet :: RSetAction Int -> RSet Int +-- Min/Max laws++findMinProp :: RSetAction Int8 -> Property+findMinProp seta+  | Set.null s  = label "trivial" $ property True+  | otherwise   = Set.findMin s === RSet.findMin rs+  where s   = rangeToSet seta+        rs  = rangeToRSet seta++findMaxProp :: RSetAction Int8 -> Property+findMaxProp seta+  | Set.null s  = label "trivial" $ property True+  | otherwise   = Set.findMax s === RSet.findMax rs+  where s   = rangeToSet seta+        rs  = rangeToRSet seta++minMaxProps :: TestTree+minMaxProps = testGroup "Min/Max properties"+  [ QC.testProperty "findMin"  findMinProp+  , QC.testProperty "findMax"  findMaxProp+  ]+ -- Monoid laws monoidLaws :: TestTree-monoidLaws = testGroup "MonoidLaws"+monoidLaws = testGroup "Monoid laws"   [ QC.testProperty "left identity"   (\a -> rs a === mempty <> rs a)   , QC.testProperty "right identity"  (\a -> rs a === rs a <> mempty)   , QC.testProperty "associativity"   (\a b c -> rs a <> (rs b <> rs c) === (rs a <> rs b) <> rs c)@@ -162,13 +184,14 @@ -- All QuickCheck properties qcProps :: TestTree qcProps = testGroup "QuickCheck properties"-  [ QC.testProperty "element operations similar" elementsProp-  , QC.testProperty "size consistent" sizeProp-  , QC.testProperty "null operation similar" nullProp-  , QC.testProperty "member operation similar" memberProp-  , QC.testProperty "notMember operation similar" notMemberProp-  , QC.testProperty "range operations similar" rangeProp-  , QC.testProperty "ranges remain ordered" orderedProp+  [ QC.testProperty "element operations are similar" elementsProp+  , QC.testProperty "size is consistent" sizeProp+  , QC.testProperty "null operation is similar" nullProp+  , QC.testProperty "member operation is similar" memberProp+  , QC.testProperty "notMember operation is similar" notMemberProp+  , QC.testProperty "range operations is similar" rangeProp+  , QC.testProperty "ranges remain is ordered" orderedProp   , complementProps+  , minMaxProps   , monoidLaws   ]