New functions are not detected by vscode Haskell extension

1.4k Views Asked by At

I have the following Visual Studio Code extensions for Haskell installed:

enter image description here

Let's say I create a new stack project:

stack new vscode-red-squiggly-test

And setup Lib.hs and Main.hs as follows:

enter image description here

This builds and runs just fine:

stack build
stack exec vscode-red-squiggly-test-exe

Now, if I add an item xyz to Lib.hs and reference it in Main.hs:

enter image description here

as you can see, a red squiggly show up under xyz.

Now, at this point, I can build and run the program just fine.

The hint when I hover over the squiggly is as follows:

enter image description here

If I close vscode, run stack build, and relaunch vscode via code ., the squiggly goes away.

So... is there a way to make the squiggly go away without having to relaunch vscode?

The suggested quick-fix is to add the following to the file:

{-# OPTIONS_GHC -Wno-deferred-out-of-scope-variables #-}

However, I'd obviously like to avoid that as it turns off the nice feature of detecting truly undefined variables.

Notes

  • My Haskell environment is running within WSL on Windows.
  • The vscode instance is running on Windows, initiated from within vscode via code ..

Update

  • I've submitted this as an issue.
1

There are 1 best solutions below

4
On

This won't help resolve your problem, which is probably a Haskell Language server bug, but the quickest way to restart Haskell Language Server in VS Code is:

  • Ctrl+Shift+P
  • Start typing until you find: Haskell: Restart Haskell LSP Server

This resolves a lot of HLS issues, and is unfortunately often neccessary, since HLs is not quite production-stable yet.

Happy Haskelling!