commercialhaskell / commercialhaskell/stack

Allow `stack build` to target sub-libraries

Open
#6,042 6 comments 1 reaction 0 assignees View on GitHub
component: build type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

Could we add `lib` as a `comptype` in docs section for target syntax?

> * _component_. Instead of referring to an entire package and letting Stack decide which components to build, you select individual components from inside a package. This can be done for more fine-grained control over which test suites to run, or to have a faster compilation cycle. There are multiple ways to refer to a specific component (provided for convenience):
>
> `packagename:comptype:compname` is the most explicit. The available comptypes are `exe`, `test`, and `bench`.
> SOURCE: [Target syntax](https://docs.haskellstack.org/en/stable/build_command/#target-syntax)

There's no mention of `lib` as `comptype` but I can use it.

```
$ stack repl stack:lib
stack> initial-build-steps (lib)
Configuring GHCi with the following packages: stack
GHCi, version 9.2.5: https://www.haskell.org/ghc/ :? for help
[ 1 of 117] Compiling Network.HTTP.StackClient
...
[117 of 117] Compiling Stack.Ls
Ok, 117 modules loaded.
ghci>
```

I see it listed as a `packagename:comptype` target:

```
$ stack ide targets
stack:lib
stack:exe:stack
stack:exe:stack-integration-test
stack:test:stack-test
```

The library name is the same as the package name but we can't use that as a `packagename:comptype:compname` target.

```
$ stack repl stack:lib:stack
Error: [S-6948]
TargetParseException ["Directory not found: stack:lib:stack"]
Note that to specify options to be passed to GHCi, use the '--ghci-options' flag.
```

When we support multiple library packages we'll need to be able to specify the `compname` of libraries. Before that feature lands we could allow `compname` for libraries.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.