haskell / haskell/haskell-mode
haskell-session-change-target unusable in cabal package with multiple library stanzas
- Dominant language
- Emacs Lisp
- Stars
- 1.4k
- Forks
- 354
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 2
Description
I have a project in which my cabal file specifies multiple libraries (since I'm using backpack) [1]. If I try to fire up an repl I have to select the correct target using haskell-session-change-target. That works well for selecting benchmarks or testsuites, however,
for each library stanza I just get a copy of "lib:" (so "lib:hgeometry-vector" in my particular case), and unfortunately that does not allow me to actually switch to the right library.
Browsing through the source a bit, I think the culprit is the [haskell-cabal-enum-targets function](https://github.com/haskell/haskell-mode/blob/a34ccdc54be15043ff0d253c3c20087524255491/haskell-cabal.el#L498) in haskell-cabal.el. In particular, it seems that on [line 520](https://github.com/haskell/haskell-mode/blob/a34ccdc54be15043ff0d253c3c20087524255491/haskell-cabal.el#L520) it is indeed creating the "lib:" instances rather than picking whatever the right session name is. While I (think) I can read enough elisp to figure out where this went wrong, I'm not really fluent enough to easily change it to do the right thing. I guess we want to keep the current behavior for the unnamed global library, but use the proper section-name (=name of the sub-library) when the section has a name).
[1] the particular package in question is https://github.com/noinia/hgeometry/tree/hgeom-1/hgeometry-vector but I don't think it should matter.
Contributor guide
Research direction
Start in haskell-cabal.el at haskell-cabal-enum-targets, especially the logic around line 520 that creates library targets. Reproduce the issue with the hgeometry-vector package and a Cabal file containing multiple named library stanzas. Done means haskell-session-change-target retains lib: for the unnamed global library while using each named sub-library's proper session name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs-lisp, haskell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100