Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Component cabal support #409

Merged
merged 3 commits into from
Aug 8, 2023
Merged

Conversation

wz1000
Copy link
Contributor

@wz1000 wz1000 commented Jun 28, 2023

Support for cabal multi-component

new versions of cabal-install (>= 3.11) have support for starting
multi-component repls which allow us to correctly load multiple components,
cruicially including the correct transitive closure of all the components we
need for correct HLS support.

This works by passing multiple targets to cabal repl, i.e.
cabal repl target1 target2 ...

In order to do this, we must know all the previous targets we have loaded,
so runCradle gets an extra [FilePath] argument so that this can be supplied.

This is the only externally visible API change in this patch.

hie-bios sometimes passes raw FilePaths as targets, and sometimes
actual component names (lib:foo, test:foo, exe:bar ...)

The latter happes when we have user configuration in the hie.yaml explicitly
specifying component names.

As downstream users of hie-bios have no concept of "component names", they
only know about files which caused a particular component to be loaded, we
must handle mapping back from FilePaths when starting a multi-component session.

It was not easy to do this with the way the code previously work with multi-cradles
and getCradle and multiAction being mutually recursive.

So now we uniformly treat everything as a multi-cradle of sorts, resolving the
configuration tree from hie.yaml (which I took care not to change) into a
list of ResolvedCradles ordered by prefixes, which can easily be consulted
by the cabal multi-component cradle to map FilePaths back to component
names when needed.

@wz1000 wz1000 force-pushed the wip/multi-component branch 3 times, most recently from 47da04a to b414480 Compare June 28, 2023 11:36
@wz1000 wz1000 force-pushed the wip/multi-component branch 2 times, most recently from 9c78985 to c86bc3b Compare July 12, 2023 08:52
new versions of cabal-install (>= 3.11) have support for starting
multi-component repls which allow us to correctly load multiple components,
cruicially including the correct transitive closure of all the components we
need for correct HLS support.

This works by passing multiple targets to `cabal repl`, i.e.
`cabal repl target1 target2 ...`

In order to do this, we must know all the previous targets we have loaded,
so `runCradle` gets an extra `[FilePath]` argument so that this can be supplied.

This is the only externally visible API change in this patch.

`hie-bios` sometimes passes raw `FilePath`s as targets, and sometimes
actual component names (lib:foo, test:foo, exe:bar ...)

The latter happes when we have user configuration in the hie.yaml explicitly
specifying component names.

As downstream users of hie-bios have no concept of "component names", they
only know about files which caused a particular component to be loaded, we
must handle mapping back from `FilePath`s when starting a multi-component session.

It was not easy to do this with the way the code previously work with multi-cradles
and `getCradle` and `multiAction` being mutually recursive.

So now we uniformly treat everything as a multi-cradle of sorts, resolving the
configuration tree from hie.yaml (which I took care not to change) into a
list of `ResolvedCradle`s ordered by prefixes, which can easily be consulted
by the cabal multi-component cradle to map `FilePath`s back to component
names when needed.
Copy link
Collaborator

@fendor fendor left a comment

Choose a reason for hiding this comment

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

LGTM!

@fendor fendor merged commit 0afdbc2 into haskell:master Aug 8, 2023
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants