@@ -167,6 +167,41 @@ For these test executables, `-p` which applies a regex filter to the test
167167names. When running ` cabal-install ` test suites, one need only use ` cabal test ` or
168168` cabal run <test-target> ` in order to test locally.
169169
170+ ## Using Haskell Language Server
171+
172+ [ Haskell Language Server] [ hls ] (HLS) works on this repository through the
173+ [ ` hie.yaml ` ] ( ./hie.yaml ) cradle in the root, which points it at the
174+ [ ` cabal.hie.project ` ] ( ./cabal.hie.project ) project rather than the default
175+ ` cabal.project ` . With that in place, there is nothing to set up beyond having
176+ an HLS that matches the ` ghc ` on your ` PATH ` .
177+
178+ > [ !WARNING]
179+ > Without ` hie.yaml ` , HLS tries to load the default project and fails with
180+ > ` Failed to parse result of calling cabal ` when the ` cabal ` on your ` PATH ` is
181+ > cabal-install 3.18 or later, including a build of this repository. HLS uses
182+ > [ hie-bios] [ hie-bios ] , which asks ` cabal repl --with-repl ` for the flags to
183+ > load the project, and that fails to resolve dependencies because
184+ > ` cabal-testsuite ` has a custom setup depending on an older and incompatible
185+ > version of ` Cabal ` . hie-bios then falls back to an older method that
186+ > cabal-install 3.18 broke. The ` cabal.hie.project ` project leaves out
187+ > ` cabal-testsuite ` , so its own code is the one part of the repository that HLS
188+ > doesn't cover.
189+
190+ To check the setup from the command line, run HLS on a file. It loads the file
191+ the same way as it would in an editor and reports what it found:
192+
193+ ```
194+ $ haskell-language-server-9.14.1 cabal-install/main/Main.hs
195+ ...
196+ Completed (1 file worked, 0 files failed)
197+ ```
198+
199+ HLS and the Haskell debugger share a build directory under ` ~/.cache/hie-bios ` ,
200+ which is why they share a project. Starting the debugger while HLS is still
201+ loading, or the other way around, can make them trip over each other in there.
202+
203+ [ hls ] : https://haskell-language-server.readthedocs.io/
204+
170205## Using the Haskell Debugger
171206
172207We can debug ` cabal ` with the [ Haskell debugger] [ hdb ] to set breakpoints, step
@@ -191,14 +226,15 @@ To get set up:
191226
192227We have a project and cradle for debugging:
193228
194- * [ ` cabal.hdb.project ` ] ( ./cabal.hdb.project ) with a subset of packages, leaving
195- out ` cabal-testsuite ` .
229+ * [ ` cabal.hie.project ` ] ( ./cabal.hie.project ) with a subset of packages, leaving
230+ out ` cabal-testsuite ` . This is the same project that Haskell Language Server
231+ uses.
196232
197233* [ ` hie-hdb.yaml ` ] ( ./hie-hdb.yaml ) uses this project and lists which components
198234 to load. Breakpoints can only be set in those components. Everything else is
199- a compiled dependency. The cradle is not named ` hie.yaml ` so that the Haskell
200- Language Server won't pick it up. This means it has to be given explicitly to
201- ` hdb ` .
235+ a compiled dependency. This is a separate cradle from the ` hie.yaml ` that
236+ Haskell Language Server uses, as it loads many components at once, so it has
237+ to be given explicitly to ` hdb ` .
202238
203239> [ !WARNING]
204240> Do not use ` cabal.project ` , the default project, for debugging. ` hdb ` tries to
0 commit comments