`template-haskell-depends`

Open
#12,583 8 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
haskell
Domain
build-system

Research direction

Start by identifying where Cabal defines, parses, and uses dependency fields such as build-depends, then trace how those fields are merged for builds. The feature is done when a template-haskell-depends field is supported and, as described here, its dependencies are merged with build-depends.

Written by the indexing model from the issue text.

Description

type: enhancement

Describe the feature request
There has long been a somewhat folkloric desire to separate out the dependencies which are needed for Template Haskell from those which are compiled and linked against.

Some people have suggested having a field like native-build-depends, but I think there is more appetite for something that is more semantically named, leaving us with some flexibility in exactly how it's used (c.f. plugin-depends).

So I suggest that we add a field template-haskell-depends for dependencies that are needed only for Template Haskell splice code. Many packages would appear in both, if they e.g. provide a splice that generates code containing identifiers from the library, in which case we also need to link against it. But some could be pure splice code.

For now, cabal would have to just merge this with build-depends since I don't think that GHC currently provides a way to take advantage of the additional information.

Additional context

I am working on buck2 support for cabal. Knowing which packages are used in TH is quite helpful, as we need to wait for their shared libraries to be built before we can proceed. At the moment we are probably going to let users specify which of their build dependencies are TH dependencies with a cabal x- extension field, but it would be nice to have a real field!

Other misc benefits:

  • A TH-only dependency doesn't have to be built with profiling support (since it won't be run at runtime)
  • In principle we could solve for TH-only dependencies separately, since they're not linked in

Non-exhaustive list of previous mentions:

Dominant language
Haskell
Stars
1.8k
Forks
766
Avg merge
5d 21h
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from haskell/cabal

All issues in haskell/cabal

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.