8

Is there a way to make intellisense work for additional modules (anything outside the prelude) like Quicktest or Random in VS Code? I am using:

  • VSCode: Version 1.55.0
  • the extension "Haskell v1.2.0" (with haskel-language-server)
  • ghci: GHCi, version 8.10.3: https://www.haskell.org/ghc/
  • stack: Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0
  • tried it direct on Windows10 and with WSL2 (Debian).

VSCode says:

Could not find module ‘Test.QuickCheck’
It is not a module in the current program, or in any known package.not found

enter image description here So, no autocomplete etc..

I think the reason is that I've installed Quicktest via stack, and that stack uses its own "isolated" ghc. So I looked for a way to configure the VSCode extension to use the ghc of my stack environment, without success.

I've also tingled with haddock and cabal, without success.

Does anybody using VS-Code to code haskell and have autocomplete, documentation on mouse over, wingman, ...?

Kraego
  • 2,978
  • 2
  • 22
  • 34
  • 2
    I think the problem is that the LSP plugin cannot extract dependencies in the test suite. One rather annoying workaround I found is to move test dependencies into global dependencies in package.yaml. Another is to [generate an hie.yaml](https://www.reddit.com/r/haskell/comments/hcu5sf/mystified_by_hieyaml/), e.g. using [implicit-hie](https://github.com/Avi-D-coder/implicit-hie), so that packages in multiple sub-components are recognized. – sshine Apr 05 '21 at 00:02
  • 1
    @Simon Shine implicit-hie is cool and solve my environment management problem, but my main problem is that intellisense in VSCode not supporting anything outside the prelude (like random, quicktest, ...), added a screenshot to question. – Kraego Apr 05 '21 at 18:03
  • Are you saying that VSCode does not support anything outside Prelude *in the test suite*, or *in general*? – sshine Apr 05 '21 at 19:56
  • 1
    In general. I have no autocomplete etc. in the editor. – Kraego Apr 05 '21 at 20:05

1 Answers1

2

I was having this problem with some local modules. I was able to fix it by placing a hie.yaml file in the project's root directory and reloading VSCode. Admittedly I don't really know what it does. I generated it using implicit-hie which you can install with stack.

  • 1
    I've already tried that, after @ Simon Shine pointed that out, it works for local modules, but not for "third party stuff", did you get autocomplete + no errors in the vs code editor when you import ```Random``` ... – Kraego May 07 '21 at 12:21
  • Oh sorry, I must have completely glossed over that... I see what you mean now. I tried importing `System.Random` and it tells me that it's from a hidden package. I was able to get it fully working by adding `random` to the `build-depends` entry in my .`cabal` file and reloading. I also ran `stack install random` just in case? – chasminimus May 07 '21 at 18:49
  • I've now tried stack + hie.yaml, + cabal. Installed random and/or added random as package ... yes it compiles and yes it runs. But the situation in the editor is still the same ... no autocomplete, no documtention on mouse hover (wingman), and the errors in output. Do you have "editor support" in VS-Code? – Kraego May 12 '21 at 10:02
  • @Kraego, did you ever find a solution? I am facing the same issues currently – sss Aug 10 '22 at 16:20
  • @sss, I didn't found a solution – Kraego Aug 10 '22 at 19:44