Skip to content

Commit 68153bb

Browse files
committed
Removes a smattering of, apparent, dead code.
Using weeder to find unused definitions. There are a great many more, but this was an attempt to be relatively conservative in the removal.
1 parent 62073c9 commit 68153bb

File tree

5 files changed

+2
-84
lines changed

5 files changed

+2
-84
lines changed

Diff for: Cabal-described/src/Distribution/Described.hs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Distribution.Described (
1313
reMunch1CS,
1414
-- * Variables
1515
reVar0,
16-
reVar1,
1716
-- * Special expressions
1817
reDot,
1918
reComma,

Diff for: Cabal-described/src/Distribution/Utils/CharSet.hs

+2-48
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ module Distribution.Utils.CharSet (
1717
difference,
1818
-- * Query
1919
size,
20-
null,
21-
member,
2220
-- * Conversions
2321
fromList,
2422
toList,
25-
fromIntervalList,
2623
toIntervalList,
2724
-- * Special lists
2825
alpha,
@@ -31,12 +28,12 @@ module Distribution.Utils.CharSet (
3128
) where
3229

3330
import Data.Char (chr, isAlpha, isAlphaNum, isUpper, ord)
34-
import Data.List (foldl', sortBy)
31+
import Data.List (foldl')
3532
import Data.Monoid (Monoid (..))
3633
import Data.String (IsString (..))
3734
import Distribution.Compat.Semigroup (Semigroup (..))
3835
import Prelude
39-
(Bool (..), Bounded (..), Char, Enum (..), Eq (..), Int, Maybe (..), Num (..), Ord (..), Show (..), String, concatMap, flip, fst, otherwise, showParen,
36+
(Bounded (..), Char, Enum (..), Eq (..), Int, Num (..), Ord (..), Show (..), String, concatMap, flip, otherwise, showParen,
4037
showString, uncurry, ($), (.))
4138

4239
#if MIN_VERSION_containers(0,5,0)
@@ -78,40 +75,15 @@ empty = CS IM.empty
7875
universe :: CharSet
7976
universe = CS $ IM.singleton 0 0x10ffff
8077

81-
-- | Check whether 'CharSet' is 'empty'.
82-
null :: CharSet -> Bool
83-
null (CS cs) = IM.null cs
84-
8578
-- | Size of 'CharSet'
8679
--
87-
-- >>> size $ fromIntervalList [('a','f'), ('0','9')]
88-
-- 16
89-
--
90-
-- >>> length $ toList $ fromIntervalList [('a','f'), ('0','9')]
91-
-- 16
92-
--
9380
size :: CharSet -> Int
9481
size (CS m) = foldl' (\ !acc (lo, hi) -> acc + (hi - lo) + 1) 0 (IM.toList m)
9582

9683
-- | Singleton character set.
9784
singleton :: Char -> CharSet
9885
singleton c = CS (IM.singleton (ord c) (ord c))
9986

100-
-- | Test whether character is in the set.
101-
member :: Char -> CharSet -> Bool
102-
#if MIN_VERSION_containers(0,5,0)
103-
member c (CS m) = case IM.lookupLE i m of
104-
Nothing -> False
105-
Just (_, hi) -> i <= hi
106-
where
107-
#else
108-
member c (CS m) = go (IM.toList m)
109-
where
110-
go [] = False
111-
go ((x,y):zs) = (x <= i && i <= y) || go zs
112-
#endif
113-
i = ord c
114-
11587
-- | Insert 'Char' into 'CharSet'.
11688
insert :: Char -> CharSet -> CharSet
11789
insert c (CS m) = normalise (IM.insert (ord c) (ord c) m)
@@ -179,24 +151,6 @@ toList = concatMap (uncurry enumFromTo) . toIntervalList
179151
toIntervalList :: CharSet -> [(Char, Char)]
180152
toIntervalList (CS m) = [ (chr lo, chr hi) | (lo, hi) <- IM.toList m ]
181153

182-
-- | Convert from interval pairs.
183-
--
184-
-- >>> fromIntervalList []
185-
-- ""
186-
--
187-
-- >>> fromIntervalList [('a','f'), ('0','9')]
188-
-- "0123456789abcdef"
189-
--
190-
-- >>> fromIntervalList [('Z','A')]
191-
-- ""
192-
--
193-
fromIntervalList :: [(Char,Char)] -> CharSet
194-
fromIntervalList xs = normalise' $ sortBy (\a b -> compare (fst a) (fst b))
195-
[ (ord lo, ord hi)
196-
| (lo, hi) <- xs
197-
, lo <= hi
198-
]
199-
200154
-------------------------------------------------------------------------------
201155
-- Normalisation
202156
-------------------------------------------------------------------------------

Diff for: Cabal-tests/Cabal-tests.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ test-suite unit-tests
3030
hs-source-dirs: tests
3131
other-modules:
3232
Test.Laws
33-
Test.QuickCheck.Utils
3433
UnitTests.Distribution.CabalSpecVersion
3534
UnitTests.Distribution.Compat.Graph
3635
UnitTests.Distribution.Compat.Time

Diff for: Cabal-tests/tests/Test/QuickCheck/Utils.hs

-29
This file was deleted.

Diff for: cabal-benchmarks/bench/CabalBenchmarks.hs

-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Distribution.Version
88

99
import qualified Data.ByteString as BS
1010

11-
import qualified Distribution.Types.VersionInterval.Legacy as Old
1211
import qualified Distribution.Types.VersionInterval as New
1312

1413
-------------------------------------------------------------------------------
@@ -38,7 +37,6 @@ main = defaultMain
3837
, env bigVersionRangeA $ \vr -> bench "pat4" $ nf f vr
3938
]
4039
in [ suite "def" normaliseVersionRange
41-
, suite "old" oldNormaliseVersionRange
4240
, suite "new" newNormaliseVersionRange
4341
]
4442
]
@@ -47,9 +45,6 @@ main = defaultMain
4745
-- VersionRanges normalisation
4846
-------------------------------------------------------------------------------
4947

50-
oldNormaliseVersionRange :: VersionRange -> VersionRange
51-
oldNormaliseVersionRange = Old.fromVersionIntervals . Old.toVersionIntervals
52-
5348
newNormaliseVersionRange :: VersionRange -> VersionRange
5449
newNormaliseVersionRange = New.normaliseVersionRange2
5550

0 commit comments

Comments
 (0)