Hello, I am being driven crazy by HLS.
Context
I am trying to work through Advent of Code 2022 and am trying to have multiple executables in a single Cabal project to keep things efficient. Below is the tree. (day-02
and day-03
have empty Main.hs
files for now.)
I am using VS Code as my editor.
.
├── CHANGELOG.md
├── data
│ ├── day_01.txt
│ ├── day_02.txt
│ └── day_03.txt
├── day-01
│ └── Main.hs
├── day-02
│ └── Main.hs
├── day-03
│ └── Main.hs
├── dist-newstyle (truncated for length)
├── hie.yaml
└── puzzles.cabal
Previously I had a lot of trouble getting HLS to work in a Cabal project, until I learnt about adding in an hie.yaml
file at the root of the Cabal project. For this particular project, hie.yaml
looks like this:
cradle:
cabal:
My hie.yaml
looks like this because, in another Cabal project, I struggled to get HLS to work, and only by adding these two lines was I finally able to get it running.
My puzzles.cabal
file looks like this:
cabal-version: 3.6
name: puzzles
version: 0.1.0.0
author: My Name
extra-source-files: CHANGELOG.md
data-dir: data
data-files:
day_01.txt
, day_02.txt
, day_03.txt
executable day-01
main-is: Main.hs
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends: base ^>= 4.17.2.0
, split == 0.2.4
hs-source-dirs: day-01
default-language: Haskell2010
executable day-02
main-is: Main.hs
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends: base ^>= 4.17.2.0
, split ^>=0.2.4
hs-source-dirs: day-02
default-language: Haskell2010
executable day-03
main-is: Main.hs
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends: base ^>= 4.17.2.0
, split ^>=0.2.4
hs-source-dirs: day-03
default-language: Haskell2010
The issue
I don’t know if HLS is working properly or not. I use Main.hs
in day-01
as an example.
module Main where
import Data.List.Split (splitOn)
main :: IO ()
main = do
raw <- readFile "./data/day_01.txt"
undefined
func :: Int -> Int -> Int
func x y = show (x + y)
parse :: String -> [[Int]]
parse input = secondPass $ firstPass input
where
firstPass :: String -> [String]
firstPass = splitOn "\n\n"
secondPass :: [String] -> [[Int]]
secondPass = map (map read . splitOn "\n")
func
was deliberately defined to be wrong. Yet, I see no highlighting anywhere in the code that there has been a mistake.
But if I were to mouse over a value like raw
, a tooltip does appear.
In the parse
function, a tooltip appears when I mouse over parse
and firstPass
. (I show a screenshot of parse
but the form of the tooltip is the same with firstPass
.)
But, when I mouse over secondPass
, no tooltip appears.
My questions
- Are these tooltips that I’m seeing part of HLS or part of something else?
- What can I do to get HLS running again? I was able to make it work in another Cabal project, but here adding the
hie.yaml
file appears to have no effect on getting the language server to work
Versions used
-
ghc
9.4.7 -
cabal
3.6.2.0-p1 -
hls
2.4.0.0 -
stack
2.11.1 -
ghcup
0.1.20.0 - macOS Ventura 13.6 (M1 Pro)
Settings JSON file in VS Code
{
"workbench.colorTheme": "Nord",
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true,
"editor.fontWeight": "450",
"files.trimTrailingWhitespace": true,
"gitlens.hovers.currentLine.over": "line",
"gitlens.currentLine.enabled": false,
"gitlens.codeLens.enabled": false,
"gitlens.defaultDateFormat": "YYYY-MM-DD hh:mm:ss",
"gitlens.defaultDateShortFormat": "YYYY-MM-DD",
"gitlens.defaultTimeFormat": "hh:mm",
"terminal.integrated.fontFamily": "Fira Code",
"editor.wordWrap": "on",
"haskell.manageHLS": "GHCup",
"security.workspace.trust.untrustedFiles": "open",
"editor.cursorBlinking": "phase",
"editor.fontSize": 12.5,
"git.autofetch": true,
"git.enableSmartCommit": true,
"terminal.integrated.fontSize": 12.5,
"haskell.serverEnvironment": {
"PATH": "${HOME}/.ghcup/bin:${PATH}"
}
}
Thanks.