Improve Bazel experience in Dante upstream
Nobody has claimed this yet.
- Dominant language
- Starlark
- Stars
- 279
- Forks
- 93
- Avg merge
- 13d 11h
- Merged PRs (30d)
- 3
Description
This is really a ticket for Dante, but filing here for this team to prioritize. Several IDE integration options today are unfortunately tied pretty tightly to the existence of Stack (unnecessarily so!). This includes intero, and hence also haskero and haskelly for VSCode (since both depend on intero). Dante shows that in the case of Emacs and likely others too, you can get pretty much all of the same features working uniformly for many build tools with very little tool-specific code (typically just a few lines in dante.el). ghcid shows something else: that no IDE integration can be workable too.
It's possible to make Dante work with Bazel today in simple cases where all source files can be provided to GHCi as-is (no system dependencies etc). You have to tell Dante that you want it to spawn a naked GHCi prompt for this to work and set dante-project-root manually. To improve on this, we need to:
- Teach Dante to recognize the project root automatically by looking for a
WORKSPACEfile. - Teach Dante what
<target-name> to use when callingbazel run @replto spawn the REPL, given the name ofWORKSPACE`-relative source file path. - (optional) make it so that Dante only uses one REPL session per
*-@repltarget, to save on memory. Since we have one*-@repltarget perhaskell_libraryorhaskell_binary, not one per source file. I don't know how hard this would be. Maybe trivial or very hard depending on the internals of Dante.
For (2), Dante internally has a buffer-local variable called dante-target, which is the name of the target to supply to the REPL. Given the filename /path/to/Foo.hs associated with the current buffer, we can compute <target-name> as follows:
fullname=$(bazel query //path/to/file/bar.java)
bazel query "attr('srcs', $fullname, ${fullname//:*/}:*)"
cc @jyp.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
This ticket is for Dante upstream; start by reading dante.el and the described dante-target behavior, then inspect how WORKSPACE-relative source paths map to Bazel targets. Done would include automatic project-root detection and target selection for Bazel REPLs; shared REPL sessions are listed as optional and may require understanding Dante internals.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs, haskell
- Domain
- build-system, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100