cabal-install-3.10.2.1: The command-line interface for Cabal and Hackage.

Safe Haskell | None
Language | Haskell2010

Distribution.Client.CmdRepl

Contents

- The `repl` CLI and action
- Internals exposed for testing

Description

cabal-install CLI command: repl

Synopsis

- replCommand :: CommandUI (NixStyleFlags (ReplOptions, EnvFlags))
- replAction :: NixStyleFlags (ReplOptions, EnvFlags) -> [String] -> GlobalFlags -> IO ()
- matchesMultipleProblem :: TargetSelector -> [AvailableTarget ()] -> ReplTargetProblem
- selectPackageTargets :: TargetSelector -> [AvailableTarget k] -> Either ReplTargetProblem [k]
- selectComponentTarget :: SubComponentTarget -> AvailableTarget k -> Either ReplTargetProblem k

# The `repl` CLI and action

replCommand :: CommandUI (NixStyleFlags (ReplOptions, EnvFlags)) #

replAction :: NixStyleFlags (ReplOptions, EnvFlags) -> [String] -> GlobalFlags -> IO () #

The `repl` command is very much like `build`. It brings the install plan up to date, selects that part of the plan needed by the given or implicit repl target and then executes the plan.

Compared to `build` the difference is that only one target is allowed (given or implicit) and the target type is repl rather than build. The general plan execution infrastructure handles both build and repl targets.

For more details on how this works, see the module Distribution.Client.ProjectOrchestration

# Internals exposed for testing

matchesMultipleProblem :: TargetSelector -> [AvailableTarget ()] -> ReplTargetProblem #

selectPackageTargets :: TargetSelector -> [AvailableTarget k] -> Either ReplTargetProblem [k] #

This defines what a `TargetSelector` means for the `repl` command. It selects the `AvailableTarget`s that the `TargetSelector` refers to, or otherwise classifies the problem.

For repl we select:

- the library if there is only one and it's buildable; or
- the exe if there is only one and it's buildable; or
- any other buildable component.

Fail if there are no buildable lib/exe components, or if there are multiple libs or exes.

selectComponentTarget :: SubComponentTarget -> AvailableTarget k -> Either ReplTargetProblem k #

For a `TargetComponent` `TargetSelector`, check if the component can be selected.

For the `repl` command we just need the basic checks on being buildable etc.