tweag / tweag/rules_haskell

Support thinning and renaming modules

Open
#358 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3 type: feature request
Dominant language
Starlark
Stars
279
Forks
93
Avg merge
13d 11h
Merged PRs (30d)
3

Description

GHC supports module thinning and module renaming. See https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html#thinning-and-renaming-modules. This feature is older than Backpack, but AFAICT was only exposed in Cabal as part of the Backpack work when they added the mixins field. We could implement this with an API like the following:

haskell_library(
  name = "foo",
  deps = [":bar", ":baz"],
  imports = {":bar": "Data.Bar1 as Data.Bar1_2, Data.Bar2 as Data.Bar2_2"},
)

We are limited to just strings as dictionary values by Skylark's current API. Which it would be annoying to have to parse. But fortunately we don't have to, and can instead pass as-is to GHC. We propose imports as the attribute name by symmetry with exports proposed in #357.

Contributor guide

Open the contributing guide

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.

Research direction

Start with the proposed imports attribute on haskell_library and read the linked GHC documentation on thinning and renaming modules. Review the related exports proposal in #357, then define the rule and integration points needed for string-valued module mappings; done means the example API works and GHC receives the mappings unchanged.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.