1

I'm getting started with Haskell and VSCode. I've forked and downloaded a repo with Haskell code. I've followed instructions for setting up a nix-shell correctly for this repo. I can successfully invoke cabal build and haskell-language-server for week 1 examples.

I've started up VSCode from within nix-shell and I can see that the language server is reporting symbol information to VSCode. For example:

enter image description here

However, I often find that if I try to Go To Definition VSCode reports that no definition is found:

enter image description here

For many of these symbols I find that if I hover my cursor over the symbol I'm shown where the symbol is defined:

enter image description here

Othertimes, I find that Go To Definition correctly resolves. For example, AuctionSchema on this line resolves correctly, while AuctionSchema on this line does not.

Why does Go To Definition only sometimes work? Is there a way to fix this?

Paymahn Moghadasian
  • 9,301
  • 13
  • 56
  • 94
  • I've same problem, I think it's a vscode bug because as you said, only sometimes work. Try to check the Output console > Tasks > Haskell , there is a log with all details. – georgeos Oct 05 '21 at 02:47
  • 1
    Looks like it's a bug with the HLS: https://github.com/haskell/haskell-language-server/issues/708 – Paymahn Moghadasian Oct 06 '21 at 15:11
  • I can't get Go To Definition to even work on functions defined in the same file. HLS seems quite broken in this regard. Are there other extensions that actually work? – Motorhead Feb 09 '22 at 21:05
  • A bit off-topic: Can I ask what is the theme you use? Looks gorgeous! – lkahtz Dec 02 '22 at 03:26
  • Hah yup, it's solarized light. https://marketplace.visualstudio.com/items?itemName=ryanolsonx.solarized – Paymahn Moghadasian Dec 03 '22 at 12:43

1 Answers1

2

I use emacs within NixOS, and I find that definitions are only found when they’re within the project I’m working on. Sometimes if I’m in src and the definition is in lib it won’t find it either. I just assumed that Haskell Language Server cannot use Cabal or Hpack to find definitions, but only follows types within the directory branch the current source resides. Yep, that’s annoying, but it seems to be what’s currently on offer.

dmvianna
  • 15,088
  • 18
  • 77
  • 106