diff --git a/Cabal-described/src/Distribution/Described.hs b/Cabal-described/src/Distribution/Described.hs index 717fd6a5c7a..59a8678d31f 100644 --- a/Cabal-described/src/Distribution/Described.hs +++ b/Cabal-described/src/Distribution/Described.hs @@ -13,7 +13,6 @@ module Distribution.Described ( reMunch1CS, -- * Variables reVar0, - reVar1, -- * Special expressions reDot, reComma, diff --git a/Cabal-described/src/Distribution/Utils/CharSet.hs b/Cabal-described/src/Distribution/Utils/CharSet.hs index 9243615c7fa..212e86a9056 100644 --- a/Cabal-described/src/Distribution/Utils/CharSet.hs +++ b/Cabal-described/src/Distribution/Utils/CharSet.hs @@ -17,12 +17,9 @@ module Distribution.Utils.CharSet ( difference, -- * Query size, - null, - member, -- * Conversions fromList, toList, - fromIntervalList, toIntervalList, -- * Special lists alpha, @@ -31,12 +28,12 @@ module Distribution.Utils.CharSet ( ) where import Data.Char (chr, isAlpha, isAlphaNum, isUpper, ord) -import Data.List (foldl', sortBy) +import Data.List (foldl') import Data.Monoid (Monoid (..)) import Data.String (IsString (..)) import Distribution.Compat.Semigroup (Semigroup (..)) import Prelude - (Bool (..), Bounded (..), Char, Enum (..), Eq (..), Int, Maybe (..), Num (..), Ord (..), Show (..), String, concatMap, flip, fst, otherwise, showParen, + (Bounded (..), Char, Enum (..), Eq (..), Int, Num (..), Ord (..), Show (..), String, concatMap, flip, otherwise, showParen, showString, uncurry, ($), (.)) #if MIN_VERSION_containers(0,5,0) @@ -78,18 +75,8 @@ empty = CS IM.empty universe :: CharSet universe = CS $ IM.singleton 0 0x10ffff --- | Check whether 'CharSet' is 'empty'. -null :: CharSet -> Bool -null (CS cs) = IM.null cs - -- | Size of 'CharSet' -- --- >>> size $ fromIntervalList [('a','f'), ('0','9')] --- 16 --- --- >>> length $ toList $ fromIntervalList [('a','f'), ('0','9')] --- 16 --- size :: CharSet -> Int size (CS m) = foldl' (\ !acc (lo, hi) -> acc + (hi - lo) + 1) 0 (IM.toList m) @@ -97,21 +84,6 @@ size (CS m) = foldl' (\ !acc (lo, hi) -> acc + (hi - lo) + 1) 0 (IM.toList m) singleton :: Char -> CharSet singleton c = CS (IM.singleton (ord c) (ord c)) --- | Test whether character is in the set. -member :: Char -> CharSet -> Bool -#if MIN_VERSION_containers(0,5,0) -member c (CS m) = case IM.lookupLE i m of - Nothing -> False - Just (_, hi) -> i <= hi - where -#else -member c (CS m) = go (IM.toList m) - where - go [] = False - go ((x,y):zs) = (x <= i && i <= y) || go zs -#endif - i = ord c - -- | Insert 'Char' into 'CharSet'. insert :: Char -> CharSet -> CharSet insert c (CS m) = normalise (IM.insert (ord c) (ord c) m) @@ -179,24 +151,6 @@ toList = concatMap (uncurry enumFromTo) . toIntervalList toIntervalList :: CharSet -> [(Char, Char)] toIntervalList (CS m) = [ (chr lo, chr hi) | (lo, hi) <- IM.toList m ] --- | Convert from interval pairs. --- --- >>> fromIntervalList [] --- "" --- --- >>> fromIntervalList [('a','f'), ('0','9')] --- "0123456789abcdef" --- --- >>> fromIntervalList [('Z','A')] --- "" --- -fromIntervalList :: [(Char,Char)] -> CharSet -fromIntervalList xs = normalise' $ sortBy (\a b -> compare (fst a) (fst b)) - [ (ord lo, ord hi) - | (lo, hi) <- xs - , lo <= hi - ] - ------------------------------------------------------------------------------- -- Normalisation ------------------------------------------------------------------------------- diff --git a/Cabal-tests/Cabal-tests.cabal b/Cabal-tests/Cabal-tests.cabal index 60ae8828610..7513ab6897e 100644 --- a/Cabal-tests/Cabal-tests.cabal +++ b/Cabal-tests/Cabal-tests.cabal @@ -30,7 +30,6 @@ test-suite unit-tests hs-source-dirs: tests other-modules: Test.Laws - Test.QuickCheck.Utils UnitTests.Distribution.CabalSpecVersion UnitTests.Distribution.Compat.Graph UnitTests.Distribution.Compat.Time diff --git a/Cabal-tests/tests/Test/QuickCheck/Utils.hs b/Cabal-tests/tests/Test/QuickCheck/Utils.hs deleted file mode 100644 index 72b517be24f..00000000000 --- a/Cabal-tests/tests/Test/QuickCheck/Utils.hs +++ /dev/null @@ -1,29 +0,0 @@ -module Test.QuickCheck.Utils where - -import Test.QuickCheck.Gen - - --- | Adjust the size of the generated value. --- --- In general the size gets bigger and bigger linearly. For some types --- it is not appropriate to generate ever bigger values but instead --- to generate lots of intermediate sized values. You could do that using: --- --- > adjustSize (\n -> min n 5) --- --- Similarly, for some types the linear size growth may mean getting too big --- too quickly relative to other values. So you may want to adjust how --- quickly the size grows. For example dividing by a constant, or even --- something like the integer square root or log. --- --- > adjustSize (\n -> n `div` 2) --- --- Putting this together we can make for example a relatively short list: --- --- > adjustSize (\n -> min 5 (n `div` 3)) (listOf1 arbitrary) --- --- Not only do we put a limit on the length but we also scale the growth to --- prevent it from hitting the maximum size quite so early. --- -adjustSize :: (Int -> Int) -> Gen a -> Gen a -adjustSize adjust gen = sized (\n -> resize (adjust n) gen) diff --git a/cabal-benchmarks/bench/CabalBenchmarks.hs b/cabal-benchmarks/bench/CabalBenchmarks.hs index 39580898e86..10c1b64ffde 100644 --- a/cabal-benchmarks/bench/CabalBenchmarks.hs +++ b/cabal-benchmarks/bench/CabalBenchmarks.hs @@ -8,7 +8,6 @@ import Distribution.Version import qualified Data.ByteString as BS -import qualified Distribution.Types.VersionInterval.Legacy as Old import qualified Distribution.Types.VersionInterval as New ------------------------------------------------------------------------------- @@ -38,7 +37,6 @@ main = defaultMain , env bigVersionRangeA $ \vr -> bench "pat4" $ nf f vr ] in [ suite "def" normaliseVersionRange - , suite "old" oldNormaliseVersionRange , suite "new" newNormaliseVersionRange ] ] @@ -47,9 +45,6 @@ main = defaultMain -- VersionRanges normalisation ------------------------------------------------------------------------------- -oldNormaliseVersionRange :: VersionRange -> VersionRange -oldNormaliseVersionRange = Old.fromVersionIntervals . Old.toVersionIntervals - newNormaliseVersionRange :: VersionRange -> VersionRange newNormaliseVersionRange = New.normaliseVersionRange2