I am playing around with the integration of the haskell language server and VsCode. More specifically, I'm going all around to understand the behavior of the HLS.
I have understood so far how it works in the following scenario
Opening a stack project
Opening a cabal Project
Having to generate a hie file if the cabal file is too old. (I have done it manually and i have used gen-hie as well)
What puzzles me is the behavior when opening a project with some standalone haskell file i.e. not part of a cabal or stack project.
As a an example i created a folder with a Test.hs file in it and opened it with VsCode, everything works. It is the output that i do not understand.
[Info - 10:50:14 PM] Starting server
[Info - 10:50:14 PM] Started LSP server in 0.00s
[Info - 10:50:14 PM] Registering IDE configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri 5126163944652757563 "file:///Users/maatari/Dev/VScode/haskell-no-project-bare"], clientSettings = hashed Nothing}
2023-04-17T21:50:14.357737Z | Info | Cradle path: Test.hs
2023-04-17T21:50:14.357932Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for Test.hs.
Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
[Info - 10:50:14 PM] Cradle path: Test.hs
[Warn - 10:50:14 PM] No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for Test.hs.
Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
2023-04-17T21:50:14.378890Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
[Info - 10:50:14 PM] invoking build tool to determine build flags (this may take some time depending on the cache)
2023-04-17T21:50:14.550243Z | Info | Interface files cache directory: /Users/******/.cache/ghcide/main-1a596a151463f2c53ee4feb14ecd276a1ccebfda
2023-04-17T21:50:14.550558Z | Info | Making new HscEnv. In-place unit ids: [main]
[Info - 10:50:14 PM] Interface files cache directory: /Users/*****/.cache/ghcide/main-1a596a151463f2c53ee4feb14ecd276a1ccebfda
So if no craddle is found, how does Vscode/LSH manage to work anyway ?
I try to emulate the situation, by using gen-hie in that scenario, but obviously as the doc says, it default to expecting a cabal file and fails.
Hence my question is, what magic is happening behind the scene when opening a project with no package manager, but only standalone hs files. Why does it work and how does it work ?
IS there a specific global configuration that is being used here. For instance with stack we know we have an implicit global project. But the documentation does not says that stack should be in the path for standalone to work. It only says:
Prerequisites (https://haskell-language-server.readthedocs.io/en/latest/installation.html#prerequisites)
For standalone .hs/.lhs files, ghc must be installed and on the PATH. The easiest way to >install it is with ghcup or chocolatey on Windows.