Skip to content

Commit 9260dac

Browse files
committed
Reuse isAsciiAlpha, remove isNum
- Follow hlint suggestion: Use isDigit - Follow hlint suggestion: Use isAsciiLower - Follow hlint suggestion: Use isAsciiUpper
1 parent 9b26df8 commit 9260dac

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

.hlint.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@
4747
- ignore: {name: "Use fromMaybe"} # 5 hints
4848
- ignore: {name: "Use fst"} # 2 hints
4949
- ignore: {name: "Use infix"} # 20 hints
50-
- ignore: {name: "Use isAsciiLower"} # 2 hints
51-
- ignore: {name: "Use isAsciiUpper"} # 2 hints
52-
- ignore: {name: "Use isDigit"} # 2 hints
5350
- ignore: {name: "Use lambda-case"} # 58 hints
5451
- ignore: {name: "Use list comprehension"} # 19 hints
5552
- ignore: {name: "Use list literal"} # 3 hints

Cabal-syntax/src/Distribution/Utils/Generic.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module Distribution.Utils.Generic
8585
import Distribution.Compat.Prelude
8686
import Prelude ()
8787

88+
import Data.Char (isAsciiLower, isAsciiUpper)
8889
import Distribution.Utils.String
8990

9091
import Data.Bits (shiftL, (.&.), (.|.))
@@ -449,9 +450,7 @@ isAscii c = fromEnum c < 0x80
449450

450451
-- | Ascii letters.
451452
isAsciiAlpha :: Char -> Bool
452-
isAsciiAlpha c =
453-
('a' <= c && c <= 'z')
454-
|| ('A' <= c && c <= 'Z')
453+
isAsciiAlpha c = (isAsciiLower c) || (isAsciiUpper c)
455454

456455
-- | Ascii letters and digits.
457456
--

Cabal/src/Distribution/Simple/FileMonitor/Types.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import Distribution.Simple.Glob.Internal
3939
import qualified Distribution.Compat.CharParsing as P
4040
import Distribution.Parsec
4141
import Distribution.Pretty
42+
import Distribution.Utils.Generic (isAsciiAlpha)
4243
import qualified Text.PrettyPrint as Disp
4344

4445
--------------------------------------------------------------------------------
@@ -211,7 +212,7 @@ instance Parsec FilePathRoot where
211212
root = FilePathRoot "/" <$ P.char '/'
212213
home = FilePathHomeDir <$ P.string "~/"
213214
drive = do
214-
dr <- P.satisfy $ \c -> (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
215+
dr <- P.satisfy isAsciiAlpha
215216
_ <- P.char ':'
216217
_ <- P.char '/' <|> P.char '\\'
217218
return (FilePathRoot (toUpper dr : ":\\"))

cabal-install/src/Distribution/Client/VCS.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,14 +629,13 @@ gitProgram =
629629
-- or annoyingly "git version 2.17.1.windows.2" yes, really
630630
(_ : _ : ver : _) ->
631631
intercalate "."
632-
. takeWhile (all isNum)
632+
. takeWhile (all isDigit)
633633
. split
634634
$ ver
635635
_ -> ""
636636
}
637637
where
638-
isNum c = c >= '0' && c <= '9'
639-
isTypical c = isNum c || c == '.'
638+
isTypical c = isDigit c || c == '.'
640639
split cs = case break (== '.') cs of
641640
(chunk, []) -> chunk : []
642641
(chunk, _ : rest) -> chunk : split rest
@@ -924,5 +923,4 @@ pijulProgram =
924923
_ -> ""
925924
}
926925
where
927-
isNum c = c >= '0' && c <= '9'
928-
isTypical c = isNum c || c == '.'
926+
isTypical c = isDigit c || c == '.'

0 commit comments

Comments
 (0)