Skip to content

Commit 3e7b0e6

Browse files
authored
Merge pull request #6556 from phadej/elem-case
Expand elem
2 parents e6e4e62 + 1da03c8 commit 3e7b0e6

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

Cabal/Distribution/Types/PkgconfigName.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ instance Pretty PkgconfigName where
5656
pretty = Disp.text . unPkgconfigName
5757

5858
instance Parsec PkgconfigName where
59-
parsec = mkPkgconfigName <$> P.munch1 (\c -> isAlphaNum c || c `elem` "+-._")
59+
parsec = mkPkgconfigName <$> P.munch1 isNameChar where
60+
-- https://gitlab.haskell.org/ghc/ghc/issues/17752
61+
isNameChar '-' = True
62+
isNameChar '_' = True
63+
isNameChar '.' = True
64+
isNameChar '+' = True
65+
isNameChar c = isAlphaNum c
6066

6167
instance NFData PkgconfigName where
6268
rnf (PkgconfigName pkg) = rnf pkg

Cabal/Distribution/Types/PkgconfigVersionRange.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pkgconfigParser = P.spaces >> expr where
8686
factor = parens expr <|> prim
8787

8888
prim = do
89-
op <- P.munch1 (`elem` "<>=^-") P.<?> "operator"
89+
op <- P.munch1 isOpChar P.<?> "operator"
9090
case op of
9191
"-" -> anyPkgconfigVersion <$ (P.string "any" *> P.spaces)
9292

@@ -98,6 +98,14 @@ pkgconfigParser = P.spaces >> expr where
9898

9999
_ -> P.unexpected $ "Unknown version operator " ++ show op
100100

101+
-- https://gitlab.haskell.org/ghc/ghc/issues/17752
102+
isOpChar '<' = True
103+
isOpChar '=' = True
104+
isOpChar '>' = True
105+
isOpChar '^' = True
106+
isOpChar '-' = True
107+
isOpChar _ = False
108+
101109
afterOp f = do
102110
P.spaces
103111
v <- parsec

Cabal/Distribution/Types/UnitId.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ instance Pretty UnitId where
7878
-- GHC accepts for @-package-id@.
7979
--
8080
instance Parsec UnitId where
81-
parsec = mkUnitId <$> P.munch1 (\c -> isAlphaNum c || c `elem` "-_.+")
81+
parsec = mkUnitId <$> P.munch1 isUnitChar where
82+
-- https://gitlab.haskell.org/ghc/ghc/issues/17752
83+
isUnitChar '-' = True
84+
isUnitChar '_' = True
85+
isUnitChar '.' = True
86+
isUnitChar '+' = True
87+
isUnitChar c = isAlphaNum c
8288

8389
-- | If you need backwards compatibility, consider using 'display'
8490
-- instead, which is supported by all versions of Cabal.

Cabal/Distribution/Types/VersionRange/Internal.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ versionRangeParser digitParser = expr
293293
factor = parens expr <|> prim
294294

295295
prim = do
296-
op <- P.munch1 (`elem` "<>=^-") P.<?> "operator"
296+
op <- P.munch1 isOpChar P.<?> "operator"
297297
case op of
298298
"-" -> anyVersion <$ P.string "any" <|> P.string "none" *> noVersion'
299299

@@ -325,6 +325,14 @@ versionRangeParser digitParser = expr
325325
">" -> pure $ laterVersion v
326326
_ -> fail $ "Unknown version operator " ++ show op
327327

328+
-- https://gitlab.haskell.org/ghc/ghc/issues/17752
329+
isOpChar '<' = True
330+
isOpChar '=' = True
331+
isOpChar '>' = True
332+
isOpChar '^' = True
333+
isOpChar '-' = True
334+
isOpChar _ = False
335+
328336
-- Note: There are other features:
329337
-- && and || since 1.8
330338
-- x.y.* (wildcard) since 1.6

0 commit comments

Comments
 (0)