Skip to content

Default package name and all targets for REPL#11452

Open
philderbeast wants to merge 8 commits intohaskell:masterfrom
cabalism:fix/repl-retarget
Open

Default package name and all targets for REPL#11452
philderbeast wants to merge 8 commits intohaskell:masterfrom
cabalism:fix/repl-retarget

Conversation

@philderbeast
Copy link
Collaborator

Fixes #11451. A follow on from #10684 that I closed because its changelog entry was already committed with #11237. This is the behaviour change of #10684 that was not included with #11237.

Uses existing tests. Some of these no longer fail if no target is supplied.


@philderbeast
Copy link
Collaborator Author

Relevant unresolved review comment from #10684.

Did you consider modifying validatedTargets, in particular the selectPackageTargets function? That seems likely to be more correct to me than this ad-hoc manipulation of target strings. #10684 (comment)

@philderbeast philderbeast force-pushed the fix/repl-retarget branch 5 times, most recently from 03507f5 to ca9dc9b Compare January 21, 2026 19:29
@philderbeast philderbeast marked this pull request as draft January 21, 2026 20:22
@philderbeast philderbeast force-pushed the fix/repl-retarget branch 4 times, most recently from 5667d09 to 047b4e3 Compare January 22, 2026 17:21
-- ^ Global flags.
-> CurrentCommand
-- ^ Current Command (usually for error reporting).
-> (TargetContext -> ProjectBaseContext -> [TargetSelector] -> IO b)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can flip the argument order here in withContextAndSelectors, a refactor, then I'd like to change TargetsAction too dropping its ProjectBaseContext argument.

diff --git a/cabal-install/src/Distribution/Client/ScriptUtils.hs b/cabal-install/src/Distribution/Client/ScriptUtils.hs
index 1c78d537c..08921b1e3 100644
--- a/cabal-install/src/Distribution/Client/ScriptUtils.hs
+++ b/cabal-install/src/Distribution/Client/ScriptUtils.hs
@@ -289,7 +289,7 @@ withContextAndSelectors
   -- ^ Global flags.
   -> CurrentCommand
   -- ^ Current Command (usually for error reporting).
-  -> (TargetContext -> ProjectBaseContext -> [TargetSelector] -> IO b)
+  -> (ProjectBaseContext -> TargetContext -> [TargetSelector] -> IO b)
   -- ^ The body of your command action.
   -> IO b
 withContextAndSelectors verbosity noTargets kind flags@NixStyleFlags{..} targetStrings globalFlags cmd act =

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps that should be a subsequent PR?

Comment on lines +406 to +407
ctx
((baseCtx, multiReplEnabled), targetSelectors) = do
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like ctx and baseCtx are the same.

@philderbeast
Copy link
Collaborator Author

Did you consider modifying validatedTargets, in particular the selectPackageTargets function? That seems likely to be more correct to me than this ad-hoc manipulation of target strings. #10684 (comment)

@mpickering, can these be constructed as [TargetPackageNamed (mkPackageName pkg) Nothing] for the package target and [TargetAllPackages Nothing] for the all target?

@philderbeast philderbeast marked this pull request as ready for review January 22, 2026 20:20
-- ^ Global flags.
-> CurrentCommand
-- ^ Current Command (usually for error reporting).
-> (TargetContext -> ProjectBaseContext -> [TargetSelector] -> IO b)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps that should be a subsequent PR?

philderbeast and others added 8 commits January 22, 2026 20:19
- Show packages when no --project-file is given
- Handle the case with no packages in the project
- Add a changelog
- Add tests
- Satisfy hlint
- Satisfy fourmolu
- Don't need a target when there is one package
- Adjust target strings for sole package
- Add alt.project tests for ReplOptions
- Silence the 1st withCtx call's verbosity
- Don't repeat configuration is affected by
- Satisfy whitespace
- Fixups after rebase
- Remove punct variable
- Review comment changes
- Comma with but joining indep' clauses
- Use single package
- Update tests, adding more assertions
- Improve test descriptions
- Mention [package:][ctype:]component
- Don't repeat [package:][ctype:]component
- Lift validatedTargets, rename r as replFlags
- Don't use -XRecordWildCards for configFlags
- Add a one.project one pkg test
- Remove target string manipulation
- Make reportProjectNoTarget a function
- Redo ReplProjectTarget tests
- Redo ReplProjectNoneTarget tests
- Satisfy fix-whitespace
- Error whether or not project has packages
- Guard against triggering an assertion if targets are null
- Skip if Windows
- Repl commands mentioning the fake-package
- Don't yet automatically pick only choice
- Autopick the one package
- Split ReplProjectTarget test
- Add tests for repl all target
- Default target to all with multireplh
- Add a retargetting message
- Add test for default "all" target when multirepl
- Add type synonym TargetPick
- Add targetedRepl
- RejectNoTargets if target strings not null
- Guard against infinite retargeting & null pkgs
- Redo the changelog.
- Remove TargetPick type synonym

Co-Authored-By: brandon s allbery kf8nh <allbery.b@gmail.com>
- Update expected fake-package-0 message
- Move only deps check
- Add type synonym, Repl t a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default targets for REPL command with a project

2 participants