packages feed

Ranged-sets 0.3.0 → 0.5.0

raw patch · 9 files changed

Files

CHANGES.txt view
@@ -50,3 +50,18 @@ ------------- Require QuickCheck >= 2.4. This changes the API for the Arbitrary and CoArbitrary instances, so it gets a version number bump.++Version 0.4.0+-------------++Added Semigroup instance.+Enabled "cabal test".+Master repository now on GitHub.++Version 0.5.0+-------------++Added Ord instance.+Added instances for DiscreteOrdered for Data.Int and Data.Word types.+Made test dependencies optional.+
Data/Ranged/Boundaries.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ ----------------------------------------------------------------------------- -- | -- Module      :  Data.Ranged.Boundaries@@ -19,8 +21,12 @@    (/>/) ) where +import Data.Int import Data.Ratio+import Data.Word+#ifdef WITH_TESTS import Test.QuickCheck+#endif  infix 4 />/ @@ -75,6 +81,42 @@    adjacent = boundedAdjacent    adjacentBelow = boundedBelow +instance DiscreteOrdered Word where+   adjacent = boundedAdjacent+   adjacentBelow = boundedBelow++instance DiscreteOrdered Word8 where+   adjacent = boundedAdjacent+   adjacentBelow = boundedBelow++instance DiscreteOrdered Word16 where+   adjacent = boundedAdjacent+   adjacentBelow = boundedBelow++instance DiscreteOrdered Word32 where+   adjacent = boundedAdjacent+   adjacentBelow = boundedBelow++instance DiscreteOrdered Word64 where+   adjacent = boundedAdjacent+   adjacentBelow = boundedBelow++instance DiscreteOrdered Int8 where+  adjacent = boundedAdjacent+  adjacentBelow = boundedBelow++instance DiscreteOrdered Int16 where+  adjacent = boundedAdjacent+  adjacentBelow = boundedBelow++instance DiscreteOrdered Int32 where+  adjacent = boundedAdjacent+  adjacentBelow = boundedBelow++instance DiscreteOrdered Int64 where+  adjacent = boundedAdjacent+  adjacentBelow = boundedBelow+   instance DiscreteOrdered Integer where    adjacent = enumAdjacent    adjacentBelow = Just . pred@@ -210,6 +252,7 @@                BoundaryBelowAll -> EQ                _        -> LT +#ifdef WITH_TESTS -- QuickCheck Generator  instance Arbitrary a => Arbitrary (Boundary a) where@@ -227,3 +270,4 @@    coarbitrary (BoundaryBelow v)  = variant (2 :: Int) . coarbitrary v    coarbitrary (BoundaryAbove v)  = variant (3 :: Int) . coarbitrary v +#endif
Data/Ranged/RangedSet.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ module Data.Ranged.RangedSet (    -- ** Ranged Set Type    RSet,@@ -23,6 +25,8 @@    -- ** Useful Sets    rSetEmpty,    rSetFull,++#ifdef WITH_TESTS    -- ** QuickCheck Properties    -- *** Construction    prop_validNormalised,@@ -54,14 +58,17 @@    prop_union_associates,    prop_de_morgan_intersection,    prop_de_morgan_union,+#endif ) where  import Data.Ranged.Boundaries import Data.Ranged.Ranges-import Data.Monoid  import Data.List++#ifdef WITH_TESTS import Test.QuickCheck+#endif  infixl 7 -/\- infixl 6 -\/-, -!-@@ -70,10 +77,12 @@ -- | An RSet (for Ranged Set) is a list of ranges.  The ranges must be sorted -- and not overlap. newtype DiscreteOrdered v => RSet v = RSet {rSetRanges :: [Range v]}-   deriving (Eq, Show)+   deriving (Show, Eq, Ord) +instance DiscreteOrdered a => Semigroup (RSet a) where+   (<>) = rSetUnion+ instance DiscreteOrdered a => Monoid (RSet a) where-    mappend = rSetUnion     mempty = rSetEmpty  -- | Determine if the ranges in the list are both in order and non-overlapping.@@ -245,6 +254,7 @@             Nothing -> []  +#ifdef WITH_TESTS -- QuickCheck Generators  instance (Arbitrary v, DiscreteOrdered v, Show v) =>@@ -484,3 +494,5 @@ prop_de_morgan_union :: (DiscreteOrdered a) => RSet a -> RSet a -> Bool prop_de_morgan_union rs1 rs2 =    rSetNegation (rs1 -\/- rs2) == (rSetNegation rs1 -/\- rSetNegation rs2)++#endif
Data/Ranged/Ranges.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ ----------------------------------------------------------------------------- -- -- Module      :  Data.Ranged.Ranges@@ -29,6 +31,8 @@    rangeIntersection,    rangeUnion,    rangeDifference,++#ifdef WITH_TESTS    -- ** QuickCheck properties    prop_unionRange,    prop_unionRangeLength,@@ -42,13 +46,17 @@    prop_emptyNonSingleton,    prop_fullNonSingleton,    prop_nonSingleton,-   prop_intSingleton+   prop_intSingleton,+#endif ) where  import Control.Monad import Data.Ranged.Boundaries import Data.Maybe++#ifdef WITH_TESTS import Test.QuickCheck+#endif  -- | A Range has upper and lower boundaries. data Ord v => Range v = Range {rangeLower, rangeUpper :: Boundary v}@@ -213,6 +221,7 @@       intersects = (max lower1 lower2) < (min upper1 upper2)  +#ifdef WITH_TESTS -- QuickCheck generators  instance (Arbitrary v,  DiscreteOrdered v, Show v) =>@@ -356,4 +365,4 @@       rangeAround v1 v2 = return Range `ap` genBound v1 `ap` genBound v2       genBound v = elements [BoundaryAbove v, BoundaryBelow v] -+#endif
− INSTALL.txt
@@ -1,14 +0,0 @@-As user, from within the project directory:--   runghc Setup.hs configure-   runghc Setup.hs build--As root or administrator:--   runghc Setup.hs install-   -If you have Haddock then generate the documentation with:--   runghc Setup.hs haddock-   -If you use Hugs then type "runhugs" instead of "runghc".
Ranged-sets.cabal view
@@ -1,14 +1,13 @@ name: Ranged-sets-version: 0.3.0-cabal-version: -any+version: 0.5.0+cabal-version: 1.24 build-type: Simple license: BSD3 license-file: LICENSE.txt-copyright: Paul Johnson, 2005, 2006, 2007, 2008+copyright: Paul Johnson, 2005, 2006, 2007, 2008, 2019, 2025 maintainer: paul@cogito.org.uk-build-depends: HUnit -any, QuickCheck >=2, base >=4 && <5 stability: beta-homepage: http://code.haskell.org/ranged-sets+homepage: https://github.com/PaulJohnson/Ranged-sets package-url: bug-reports: synopsis: Ranged sets for Haskell@@ -21,34 +20,34 @@              >    ("F" <= s < "G") category: Data author: Paul Johnson-tested-with:-data-files:-data-dir: ""-extra-source-files: CHANGES.txt INSTALL.txt README.txt TODO.txt-                    tests/Main.hs tests/Makefile-extra-tmp-files:-exposed-modules: Data.Ranged Data.Ranged.Ranges+extra-doc-files: CHANGES.txt README.txt++flag with-tests+    description: Include unit tests / extra  instances.+    default: True+    manual: False++library+    build-depends: base >=4.11 && <5+    if flag(with-tests)+        cpp-options: -DWITH_TESTS+        build-depends: QuickCheck >=2 && < 3+    exposed-modules: Data.Ranged Data.Ranged.Ranges                  Data.Ranged.RangedSet Data.Ranged.Boundaries-exposed: True-buildable: True-build-tools:-cpp-options:-cc-options:-ld-options:-pkgconfig-depends:-frameworks:-c-sources:-extensions:-extra-libraries:-extra-lib-dirs:-includes:-install-includes:-include-dirs:-hs-source-dirs: .-other-modules:-ghc-prof-options:-ghc-shared-options:-ghc-options: -Wall-hugs-options:-nhc98-options:-jhc-options:+    exposed: True+    buildable: True+    default-language: Haskell2010+++Test-suite properties+    type: exitcode-stdio-1.0+    default-language: Haskell2010+    main-is: Main.hs+    hs-source-dirs: tests .+    cpp-options: -DWITH_TESTS+    other-modules: Data.Ranged Data.Ranged.Ranges+                 Data.Ranged.RangedSet Data.Ranged.Boundaries+    build-depends:+        base >= 4 && < 5,+        HUnit,+        QuickCheck
− TODO.txt
@@ -1,13 +0,0 @@-Things to do:-  -* Test with yhc.--* Define ranges of times and dates.  The set of all Mondays, for instance,-  or the set of all second weeks in the month.  Any such functions would-  have to take a start date because the only alternative is to start-  with the epoch, and that would not be efficient.  The existing date-time-  functions look a bit clunky for this job, but the proposals of-  Ashley Yakeley at http://semantic.org/TimeLib/ look more suitable.---  
tests/Main.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS_GHC -fglasgow-exts #-}+{-# LANGUAGE ScopedTypeVariables #-}  module Main where @@ -8,7 +8,7 @@   conf :: Args-conf = stdArgs { maxSuccess = 1000, maxDiscard = 10000 }+conf = stdArgs { maxSuccess = 1000, maxDiscardRatio = 100 }  check :: (Test.QuickCheck.Testable prop) => prop -> IO () check = quickCheckWith conf
− tests/Makefile
@@ -1,16 +0,0 @@-# Tests for Ranged Sets.--all:-	ghc --make -fhpc -i.. -odir . -hidir . -Wall Main.hs -o test-rset-	rm -f test-rset.tix-	./test-rset-	hpc markup --destdir=Report test-rset-	hpc report test-rset--clean:-	rm -fR Data-	rm -f test-rset.tix-	rm -f test-rset-	rm -f *.o *.hi-	rm -fR Report-