Skip to content

Commit 47d5634

Browse files
telserMikolaj
authored andcommitted
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 c2f046b commit 47d5634

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,
@@ -32,12 +29,12 @@ module Distribution.Utils.CharSet (
3229
) where
3330

3431
import Data.Char (chr, isAlpha, isAlphaNum, isDigit, isUpper, ord)
35-
import Data.List (foldl', sortBy)
32+
import Data.List (foldl')
3633
import Data.Monoid (Monoid (..))
3734
import Data.String (IsString (..))
3835
import Distribution.Compat.Semigroup (Semigroup (..))
3936
import Prelude
40-
(Bool (..), Bounded (..), Char, Enum (..), Eq (..), Int, Maybe (..), Num (..), Ord (..), Show (..), String, (&&), concatMap, flip, fst, not, otherwise, showParen,
37+
(Bounded (..), Char, Enum (..), Eq (..), Int, Num (..), Ord (..), Show (..), String, (&&), concatMap, flip, not, otherwise, showParen,
4138
showString, uncurry, ($), (.))
4239

4340
#if MIN_VERSION_containers(0,5,0)
@@ -79,40 +76,15 @@ empty = CS IM.empty
7976
universe :: CharSet
8077
universe = CS $ IM.singleton 0 0x10ffff
8178

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

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

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

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

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)