Skip to content

Allow commas inside braces in project package globs - #12172

Open
philderbeast wants to merge 11 commits into
haskell:masterfrom
cabalism:test/parse-packages-glob
Open

philderbeast wants to merge 11 commits into
haskell:masterfrom
cabalism:test/parse-packages-glob

Conversation

@philderbeast

@philderbeast philderbeast commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

The failing test for #12171 and its fix.

$ cabal test cabal-install:parser-tests
...
Build profile: -w ghc-9.10.3 -O1
...
Running 1 test suites...
Test suite parser-tests: RUNNING...
project files parsec tests                                                                                                                                                                                                                            
  read packages:                                    OK
  read packages glob:                               FAIL
    Exception: Error: [Cabal-7167]
    Error parsing project file cabal.glob.project:
    
    cabal.glob.project:3:28: error:
      unexpected ','
      expecting white space, string, identifier or end of input
          3 | packages: */*.cabal ../{foo,bar}/
            |                            ^    
    
    Use -p '/read packages glob/' to rerun this test only.

I'll squash commits before applying the merge label if this pull request is approved.


@philderbeast philderbeast changed the title Add packages glob parser test Fix packages glob parsing Jul 28, 2026
@philderbeast philderbeast changed the title Fix packages glob parsing Fix project packages glob parsing Jul 28, 2026
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch from 86f5fcc to 6fb47bd Compare July 28, 2026 19:45
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch 2 times, most recently from 5048f32 to 6b3a2e2 Compare August 2, 2026 01:03
@Mikolaj

Mikolaj commented Aug 6, 2026

Copy link
Copy Markdown
Member

Where are the globs handled in the code? I only see the curly braces syntax, which is only the half of the example in the issue.

@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch from 6b3a2e2 to f3c26eb Compare August 11, 2026 14:13
@philderbeast
philderbeast marked this pull request as draft August 13, 2026 17:11
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch 2 times, most recently from 2851518 to f01b796 Compare August 13, 2026 17:22
@philderbeast
philderbeast marked this pull request as ready for review August 13, 2026 17:22
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch from f01b796 to 0a1d051 Compare August 13, 2026 19:44
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch 2 times, most recently from f5d3e2f to cd1bfbd Compare August 25, 2026 14:42
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch from cd1bfbd to aa36c4d Compare September 23, 2026 17:25
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch from aa36c4d to edb8931 Compare November 3, 2026 16:44
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch from edb8931 to ab585e7 Compare November 3, 2026 20:22
@philderbeast
philderbeast force-pushed the test/parse-packages-glob branch from e869050 to 17943d4 Compare November 3, 2026 22:11
@philderbeast

philderbeast commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

Where are the globs handled in the code? I only see the curly braces syntax, which is only the half of the example in the issue.

Globs are handled in checkIsFileGlobPackage:

checkIsFileGlobPackage pkglocstr =
case simpleParsec pkglocstr of
Nothing -> return Nothing
Just glob ->
Just <$> do
matches <- matchFileGlob glob
case matches of
[]
| isJust (isTrivialRootedGlob glob) ->
return
( Left
( BadPackageLocationFile
(BadLocNonexistentFile pkglocstr)
)
)
[] -> return (Left (BadLocGlobEmptyMatch pkglocstr))
_ -> do
(failures, pkglocs) <-
partitionEithers
<$> traverse checkFilePackageMatch matches
return $! case (failures, pkglocs) of
([failure], [])
| isJust (isTrivialRootedGlob glob) ->
Left (BadPackageLocationFile failure)
(_, []) -> Left (BadLocGlobBadMatches pkglocstr failures)
_ -> Right pkglocs

The simpleParsec function calls parsecGlob by way of instances for Parsec RootedGlob and Parsec Glob.

parsecGlob :: CabalParsing m => m GlobPieces
parsecGlob = some parsecPiece
where
parsecPiece = P.choice [literal, wildcard, union]
wildcard = WildCard <$ P.char '*'
union = Union . toList <$> P.between (P.char '{') (P.char '}') (P.sepByNonEmpty parsecGlob (P.char ','))
literal = Literal <$> some litchar

We only needed to fix the curly braces parsing. I've changed the pull request's title and the changelog to say that.

@philderbeast philderbeast changed the title Fix project packages glob parsing Allow commas inside braces in project package globs Nov 11, 2026
@mergify mergify Bot added the 1️⃣ more approval needed Set by Mergify: has one of the two required approvals label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attention: needs-review 1️⃣ more approval needed Set by Mergify: has one of the two required approvals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants