Git Product home page Git Product logo

vscode-haskell's Introduction

Haskell for Visual Studio Code

vsmarketplacebadge

This extension adds language support for Haskell, powered by the Haskell Language Server. As almost all features are provided by the server you might find interesting read its documentation.

Table of Contents

Setup

This Extension comes with "batteries"-included and can manage your Haskell Language Server installations for you, powered by GHCup. Installation of GHCup can not happen automatically, so if you want your HLS installations to be managed by the Extension, you will have to follow the installation instructions for GHCup.

Note: Make sure you have a working ghcup installation, before launching the Extension.

Features

You can watch demos for some of these features here.

Requirements

  • For standalone .hs/.lhs files, ghc must be installed and on the PATH. The easiest way to install it is with ghcup.
  • For Cabal based projects, both ghc and cabal-install must be installed and on the PATH. It can also be installed with ghcup or Chocolatey on Windows.
  • For Stack based projects, stack must be installed and on the PATH and must be configured to use GHC binaries installed by GHCup.
  • If you are installing from an offline VSIX file, you need to install language-haskell too after installation (either from the marketplace or offline).
  • Alternatively, you can let the extension manage your entire toolchain automatically (you'll be asked on first startup) via ghcup, which should be pre-installed

Configuration options

For a general picture about the server configuration, including the project setup, you can consult the server documentation about the topic.

For information on how to set configuration in VSCode, see here.

Path to server executable

If your server is manually installed and not on your path, you can also manually set the path to the executable.

"haskell.serverExecutablePath": "~/.local/bin/haskell-language-server"

There are a few placeholders which will be expanded:

  • ~, ${HOME} and ${home} will be expanded into your users' home folder.
  • ${workspaceFolder} and ${workspaceRoot} will expand into your current project root.

Security warning

The option has machine-overridable scope so it can be changed per workspace. This supposes it could be used to execute arbitrary programs adding a .vscode/settings.json in the workspace folder including this option with the appropriate path. See #387 for more details.

Set additional environment variables for the server

You can add additional environment variables for the lsp server using the configuration option haskell.serverEnvironment. For example, to change the cache directory used by the server you could set:

{ "haskell.serverEnvironment": { "XDG_CACHE_HOME": "/path/to/my/cache" } }

as the server uses the XDG specification for cache directories.

The environment only will be visible for the lsp server, not for other extension tasks like find the server executable.

Downloaded binaries

This extension will download haskell-language-server binaries and the rest of the toolchain if you selected to use GHCup during first start. Check the haskell.manageHLS setting.

It will then download the newest version of haskell-language-server which has support for the required ghc. That means it could use an older version than the latest one, without the last features and bug fixes. For example, if a project needs ghc-8.10.4 the extension will download and use haskell-language-server-1.4.0, the latest version which supported ghc-8.10.4. Even if the latest global haskell language-server version is 1.5.1.

If you have disk space issues, check ghcup gc --help.

You can also instruct the extension to use a different installation directory for the toolchain, e.g. to not interfere with system GHCup installation. Depending on your platform, add the full resolved path like so:

  "haskell.serverEnvironment": {
    "GHCUP_INSTALL_BASE_PREFIX": "/home/foo/.config/Code/User/globalStorage/haskell.haskell/"
  }

The internal storage paths for the extension depend on the platform:

Platform Path
macOS ~/Library/Application\ Support/Code/User/globalStorage/haskell.haskell/.ghcup
Windows %APPDATA%\Code\User\globalStorage\haskell.haskell\ghcup
Linux $HOME/.config/Code/User/globalStorage/haskell.haskell/.ghcup

If you want to manage HLS yourself, set haskell.manageHLS to PATH and make sure HLS is in your PATH or set haskell.serverExecutablePath (overrides all other settings) to a valid executable.

If you need to set mirrors for ghcup download info, check the settings haskell.metadataURL and haskell.releasesURL.

Setting a specific toolchain

When manageHLS is set to GHCup, you can define a specific toolchain (hls, ghc, cabal and stack), either globally or per project. E.g.:

{
  "haskell.toolchain": {
    "hls": "1.6.1.1",
    "cabal": "recommended",
    "stack": null
  }
}

This means:

  1. install the ghc version corresponding to the project (default, because it's omitted)
  2. install hls 1.6.1.1
  3. install the recommended cabal version from ghcup
  4. don't install any stack version

Another config could be:

{
  "haskell.toolchain": {
    "ghc": "9.2.2",
    "hls": "latest",
    "cabal": "recommended"
  }
}

Meaning:

  1. install ghc 9.2.2 regardless of what the project requires
  2. always install latest hls, even if it doesn't support the given GHC version
  3. install recommended cabal
  4. install latest stack (default, because it's omitted)

The defaults (when omitted) are as follows:

  1. install the project required ghc (corresponding to with-compiler setting in cabal.project for example)
  2. install the latest hls version that supports the project required ghc version
  3. install latest cabal
  4. install latest stack

When a the value is null, the extension will refrain from installing it.

At last, if you don't want ghcup to manage any of the external tools except hls, you can use:

{
  "haskell.toolchain": {
    "ghc": null,
    "cabal": null,
    "stack": null
  }
}

Supported GHC versions

You can check each GHC version's support status and the policy followed for deprecations here.

Building from source may support more versions!

The exact list of binaries can be checked in the last release of haskell-language-server: https://github.com/haskell/haskell-language-server/releases/latest

Using multi-root workspaces

First, check out what multi-root workspaces are. The idea of using multi-root workspaces, is to be able to work on several different Haskell projects, where the GHC version or stackage LTS could differ, and have it work smoothly.

The language server is now started for each workspace folder you have in your multi-root workspace, and several configurations are on a resource (i.e. folder) scope, instead of window (i.e. global) scope.

Investigating and reporting problems

  1. Go to extensions and right click Haskell and choose Extensions Settings
  2. Scroll down to Haskell › Trace: Server and set it to messages.
  3. Set Haskell › Trace: Client to debug. It will print all the environment variables so take care it does not contain any sensitive information before sharing it.
  4. Restart vscode and reproduce your problem
  5. Go to the main menu and choose View -> Output (Ctrl + Shift + U)
  6. On the new Output panel that opens on the right side in the drop down menu choose Haskell (<your project>)

Please include the output when filing any issues on the haskell-language-server issue tracker.

FAQ

Troubleshooting

Check issues and tips in the haskell-language-server project

Restarting the language server

  • Sometimes the language server might get stuck in a rut and stop responding to your latest changes. Should this occur you can try restarting the language server with Ctrl shift P/ shift P > Restart Haskell LSP Server.

Failed to get project GHC version on darwin M1 with stack

If you have installed stack via the official cannels, the binary will not be M1 native, but x86 and trigger the rosetta compatibility layer. GHCup provides real stack/HLS M1 binaries, so make sure you install stack via GHCup. Also see haskell/haskell-language-server#2864

GHC ABIs don't match

If you are using certain versions of GHC (such as 9.0.2 or 9.2.4) while running Stack, you may encounter this issue due to an outdated GHC bindist installed by Stack. The vscode-haskell extension does not support the use of GHC binaries managed by Stack. Therefore, it is recommended to configure Stack to allow GHCup to install these binaries instead. Please refer to the instructions provided by ghcup for this purpose.

If you really want to use GHC 9.0.2 managed by Stack, force it to install the fixed bindist (that includes profiling libs) by adding this to your stack.yaml (depending on your platform):

setup-info:
  ghc:
    linux64-tinfo6:
      9.0.2:
        url: 'https://downloads.haskell.org/ghc/9.0.2/ghc-9.0.2a-x86_64-fedora27-linux.tar.xz'

Now make sure to remove cached/installed libraries to avoid getting segfaults at runtime.

As a final workaround, you can try to compile HLS from source (the extension should pick it up) via ghcup, see https://haskell-language-server.readthedocs.io/en/stable/installation.html#ghcup. In any case, the recommended approach is to let GHCup install the GHC binaries.

hGetContents: invalid argument (invalid byte sequence)

This problem was encountered on darwin M2 with ghcup. Should you see the error that the "Haskell server crashed 5 times in the last 3 minutes," you can check the Haskell output to see whether this was due to an error mentioning hGetContents: invalid argument (invalid byte sequence). If this is the case, setting terminal.integrated.detectLocale to off might resolve your issue.

Using an old configuration

If something just doesn't work, but you recall an old configuration that did, you may try forcing a particular setting, e.g. by disabling all automatic installations except HLS:

    "haskell.toolchain": {
        "hls": "1.6.1.0",
        "ghc": null,
        "cabal": null,
        "stack": null
    }

Stack/Cabal/GHC can not be found

Also make sure GHCup is installed and in $PATH. If you're not starting VSCode from the terminal, you might need to add ${HOME}/.ghcup/bin to PATH like so:

  "haskell.serverEnvironment": {
    "PATH": "${HOME}/.ghcup/bin:$PATH"
  }

Contributing

If you want to help, get started by reading Contributing for more details.

Release Notes

See the Changelog for more details.

vscode-haskell's People

Contributors

1ay1 avatar alanz avatar alexeyraga avatar berberman avatar chrismwendt avatar dependabot[bot] avatar dunetsnm avatar expipiplus1 avatar fendor avatar flip111 avatar gdziadkiewicz avatar georgefst avatar halhenke avatar hasufell avatar ismailmustafa avatar jacobprudhomme avatar jneira avatar july541 avatar lukel97 avatar mduerig avatar olivermadine avatar pepeiborra avatar pranaysashank avatar rvighne avatar soiamsong avatar tehnix avatar verymilkyjoe avatar vikrem avatar worldsender avatar wz1000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-haskell's Issues

Applying HLint Suggestions does not work at all

Hi,

I saw #33 but in my case applying hlint suggestions does not work at all.
kapture 2018-04-01 at 10 39 54
And this is the output (note the Nothing for _documentChanges)
bildschirmfoto 2018-04-01 um 10 45 43

I use the latest versions of vscode insiders, hie server and engine.
Thanks!

No hoogle db found

Upon pulling and installing a more recent version of hie, I've started getting the following warning when opening a Haskell project in vscode:

image

I'm running the following versions of hie and hoogle:

Version 0.1.0.0, Git revision 2dfb5d8635a233c9765ed11c5fc299f68adea91f (963 commits) x86_64
Hoogle 5.0.12, http://hoogle.haskell.org/

Hoogle is installed globally using stack and I've run hoogle generate globally as well.

Add --recurse-submodules in README during HIE cloning

HIE uses submodules and by default git doesn't clone them. This then leads to errors if doing a stack install straight afterwards. The fix is:

git clone --recurse-submodules https://github.com/haskell/haskell-ide-engine

An option to specify path to HIE wrapper »per project«?

It would be very useful for running HIE in context of a nix-shell for the project. 🙏

For example using a wrapper similar to: https://github.com/michalrus/kornel/blob/fd314f372e8316a9642f07b1ccf6793ed486b667/hie.sh — one which works very well with lsp-haskell in Emacs.


It would also be very useful if we could just say “use hie.sh in a dominating directory”, meaning the first hie.sh up in the directory tree starting from this file; similar to how this can be done in Emacs:

https://github.com/michalrus/dotfiles/blob/bdc726eb8847a9f70275587001d37fb489a9b059/dotfiles/emacs/.emacs.d/init.d/080-proglang-haskell.el#L32-L34

Applying HLint Suggestions does not work properly

Sometimes it doesnt delete the old code and just append everything after the entire code block

--getInts = fmap (map read . words) getLine
getInts = fmap ((map read). words) getLine

turns into

--getInts = fmap (map read . words) getLine
getInts = fmap ((map read). words) getLine--getInts = fmap (map read . words) getLine

getInts = fmap (map read. words) getLine

and another one:

main :: IO ()
countFac :: Int -> Int -> Int

main = do
    getLine
    a_temp <- getLine
    let a = map read $ words a_temp :: [Int]
    b_temp <- getLine
    let b = map read $ words b_temp :: [Int]
    let l = foldl lcm (head a) (tail a) --THIS LINE IS TO BE REPLACED WITH foldl1
    let g = foldl1 gcd b
    let s = g `div` l
    if s * l /= g
        then do
            print 0
            return ()
        else do
    print (countFac s 1)
    return ()

countFac n c
    | c > n `div` 2 = 1
    | n `div` c * c == n = 1 + countFac n (c+1)
    | otherwise = countFac n (c+1)

turns into

main :: IO ()
countFac :: Int -> Int -> Int

main = do ---THE getLine HERE IS MISSING
    a_temp <- getLine
    let a = map read $ words a_temp :: [Int]
    b_temp <- getLine
    let b = map read $ words b_temp :: [Int]
    let l = foldl lcm (head a) (tail a) --IT'S STILL HERE
    let g = foldl1 gcd b
    let s = g `div` l
    if s * l /= g
        then do
            print 0
            return ()
        else do
    let l = foldl1 lcm a -- IT GOT APPENDED HERE
countFac n c
    | c > n `div` 2 = 1
    | n `div` c * c == n = 1 + countFac n (c+1)
    | otherwise = countFac n (c+1)

I'm using Caps so that it would be easier to locate them

Red underline is missing for compilation errors

I am not sure if it is an issue with the plugin or with https://github.com/haskell/haskell-ide-engine so I report it here.

At some point in time HIE stopped reporting compilation errors. It used to be (and it should be) a red line indicating an error when the code is not right, but it is not there anymore for most of the cases.

I reproduce it by deliberately making a compilation error (put a space in side a function name somewhere, e.g. fr omIntegral) and HIE doesn't highlight the problem.

Cannot read property 'document' of undefined

Windows 10
VCode 1.22.2
Haskell Language Server 0.0.15
Haskell Syntax Highlighting 2.4.0

Stack (version 1.6.5) project, resolver: nightly-2018-04-09.

When opened with no editor tabs, in Developer Tools console:

/C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:260 [Extension Host] No editors associated with document: c:\Users\zmtemp\Desktop\haskell\gtk\haskell-gi\examples\advanced\Cairo.hs

[Extension Host] TypeError: Cannot read property 'document' of undefined
	at Object.registerCommand (C:\Users\zmtemp\.vscode\extensions\alanz.vscode-hie-server-0.0.15\out\src\commands\showType.js:78:58)
	at activateHieNoCheck (C:\Users\zmtemp\.vscode\extensions\alanz.vscode-hie-server-0.0.15\out\src\extension.js:185:36)
	at C:\Users\zmtemp\.vscode\extensions\alanz.vscode-hie-server-0.0.15\out\src\extension.js:75:17
	at Generator.next (<anonymous>)
	at fulfilled (C:\Users\zmtemp\.vscode\extensions\alanz.vscode-hie-server-0.0.15\out\src\extension.js:4:58)
	at <anonymous>
t.log @ /C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:260

After a Haskell source opened this message appears:

[Extension Host] Error: command 'hie.commands.insertType' already exists
	at e.registerCommand (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:594:33)
	at Object.registerTextEditorCommand (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\node\extensionHostProcess.js:656:876)
	at Object.registerCommand (C:\Users\zmtemp\.vscode\extensions\alanz.vscode-hie-server-0.0.15\out\src\commands\insertType.js:9:39)
	at activateHieNoCheck (C:\Users\zmtemp\.vscode\extensions\alanz.vscode-hie-server-0.0.15\out\src\extension.js:184:60)
	at C:\Users\zmtemp\.vscode\extensions\alanz.vscode-hie-server-0.0.15\out\src\extension.js:75:17
	at Generator.next (<anonymous>)
	at fulfilled (C:\Users\zmtemp\.vscode\extensions\alanz.vscode-hie-server-0.0.15\out\src\extension.js:4:58)
	at <anonymous>
t.log @ console.ts:136
t._logExtensionHostMessage @ extensionHost.ts:395
(anonymous) @ extensionHost.ts:210
emitTwo @ events.js:106
emit @ events.js:194
process.nextTick @ internal/child_process.js:766
_combinedTickCallback @ internal/process/next_tick.js:73
_tickCallback @ internal/process/next_tick.js:104

No lint, no suggestions, no intellisense.

I feel this may be due to the version of GHC (8.4.1). If so, can we solve this problem?

Add an option for only checking on file save

Currently this plugin seems to rechecking the file on each edit. This uses quite a lot of CPU and can adversely affect your laptop's battery life.

It would be nice if there was an option for this plugin to only check for errors in a file when the file is saved.

Optional special rendering of Haskell keywords

I always wanted to do that 🙂
I would like vscode to render forall as ∀, \ as λ etc. without actually writing unicode. I don't know if it's feasable, but if it's not much work, i would try to find an evening dedicated to solving this problem. I would make it optional though.

Snippets?

Was wondering if we might want to add some snippets - or is this something that you would rather see in a separate, specific extension?

Go To Definition opens a weird tab

When I click F12 (or Go To Definition in a menu) it indeed opens the definition, but in a new tab with a weird title:

image

It would be great if it was opening the real file instead.

Add setting for multiple hie versions

The hie executable is built based on a particular GHC version, and as it uses the GHC API and loads the project using it, the hie GHC and project GHC must match.

hie can now be built for GHC 8.0.2, 8.2.1 and 8.2.2.

Provide a client-side setting to choose a specific hie executable for a project.

Apply hlint suggestion from a list always applies first

#Sometimes there are more than one hlint suggestion for a given line. In this case, when the light bulb is clicked, VSCode shows a popup list of options to chose from.

It looks like currently the choice doesn't matter: clicking on any fix from that list always applies the 1st suggestion.

multi-hlints

We need windows startup support

Currently this extension assumes linux, and calls a bash file.

20:28 <alanz> Friedem: We need someone who knows how to write a batch file equivalent of https://github.com/alanz/vscode-hie-server/blob/master/hie-vscode.sh
20:29 <alanz> Friedem: can you try make one similar to this: https://github.com/phoityne/phoityne-vscode/blob/master/vscode-extension/phoityne-vscode.bat
20:30 <alanz> where the error bit is the same message as in hie-vscode.sh
20:33 <Friedem> yea I will try that
20:34 <alanz> thanks. And if you get it going please make a PR.
20:34 <alanz> you will probably have to do something here too: https://github.com/alanz/vscode-hie-server/blob/master/src/extension.ts#L31
20:35 <alanz> Not sure how to make it cross-platform
20:37 <alanz> Here is where the phoityne debugger sets it. https://github.com/phoityne/phoityne-vscode/blob/master/vscode-extension/package.json#L52
20:37 <alanz> But that is not using the language server protocol
20:37 <alanz> but perhaps there is a property we could set somehoe

Windows - %TEMP% variable is not dereferenced

HIE crashes when attempting to run it when hieExecutablePath is set on Windows. debugArgs uses %PATH%, but this environment variable is not substituted when the command is actually run, so that HIE cannot actually find the log file directory.

Support typescript-2.7.2

Using the latest git, when I do npm run compile (which I believe vsce package does), I get the error:

C:\Neil\vscode-hie-server>npm run compile

> [email protected] compile C:\Neil\vscode-hie-server
> tsc -p ./

src/commands/showType.ts(116,5): error TS2322: Type '[Disposable, OutputChannel]' is not assignable to type '[Disposable]'.
  Types of property 'length' are incompatible.
    Type '2' is not assignable to type '1'.

I am using tsc --version == 2.7.2 on Windows.

Type errors are shown only from /var/private, but not in source file

When I do some type errors in source file in VSCode, those are not shown in the Editor, although I can see its in Problems pane:
image

Please notice I have named not existing function tableWithSelectors1SHOULDWARNHERE although there is no warn in Editor, but I can see a lot of files from /var/private in Problems on the right of the screen.

I tried it with both GHC-8.2 and GHC-8.4, system is Mac OS High Sierra, I have reinstalled hie about 5 times and no success. I just do git clone ... --recursive, than one time I tried to checkout to hie-0.1.0.0 with no success, tried to use directly master, no success.

Add tslint?

Have been mucking around with adding an option to show the output of the Show Type command on hover (much like in the ide-haskell plugin for Atom). Never really mucked around with Typescript or VSCode API but have missed having eslint in terms of catching some other obvious errors (shadowing variable names etc) and providing consistency. To that end I think it might be nice to add tslint to the project. It definitely helped track down some errors while i was refactoring a bit of code.

If this sounds good I would be happy to submit a PR?

Warnings for non-exhaustive pattern matches?

I've noticed that I'm not getting warnings for non-exhaustive pattern matches. Here's an example:

eval (Plus, ns) = sum ns
eval (Minus, n:ns) = n - sum ns -- sum [] == 0
eval (Times, ns) = product ns
eval (Divide, n:ns) = n / product ns

(The cases (Minus, []) and (Divide, []) aren't handled.)

Stack notices this when I build with the --pedantic flag:

/home/mgreenbe/my-project/app/Main.hs:33:5: warning: [-Wincomplete-patterns]
    Pattern match(es) are non-exhaustive
    In an equation for ‘eval’:
        Patterns not matched:
            (Minus, [])
            (Divide, [])

Should the linter catch this?

Also, should I file this against a different repo, the linter or the HIE server itself?

HIE stops working when doing a `stack build` OSX

Greetings,

First, I'm very sorry for not being able to come up with a more descriptive title, but it is what I'm experiencing.

HIE is working (all the types information and hoogle documentation) but for an unknown reason, after some time, it stops and keeps displaying Loading message when I'm hovering a symbol. That behavior persists even when I restart VS Code, or Uninstall / Install HIE.

It does this behavior for all the projects I have. I hardly believe it's because of a time constraint of course. It has to come from my dev workflow but hard to found out as no error message shows up.

Thanks for your time.

env:

  • OSX High Sierra
  • HIE: 2.4.0
  • Code: 1.22.2
  • GHC: 8.2.2
  • Stack: 1.6.5

Support for Test Suites?

Hi,

I am currently testing the VSCode extension for HIE. So far, my test project is looking good in VSCode/HIE, but the included test suite does not seem to be "working" out of the box: Its dependencies do not seem to be "in scope". The package.yaml contains the following:

tests:
[…]
    dependencies:
[…]
    - test-framework
    - test-framework-hunit

ghcmod says:

Could not find module 'Test.Framework' Use -v to see a list of the files searched for.

along with some other modules, which are imported by the test module.

When I use Intero in Emacs, I use M-x intero-targets to specify that I want both "targets" — the main library plus the test suite — loaded. Is something similar required for VSCode/HIE?

Thanks!
Moritz

The readmes aren't in sync

Hi
I'm trying to create my own language server so I was trying to use this as a simple example.
I think the instructions are not up to date anymore or something.
https://github.com/alanz/haskell-lsp
Simply running the extension does not create the tmp file as I would expect

https://github.com/alanz/vscode-hie-server/blob/master/vsc-extension-quickstart.md
it says that there is a registerCommand function being invoked but I can't find it anywhere

I'm using the current master

Issues with multiple servers after upgrading languageclient to 4.1.3

Currently tracked in microsoft/vscode-languageserver-node#333.

After upgrading vscode-languageclient from 3.5.0 to 4.1.3, we are having problems with multiple spawned language servers, which is needed for multi-root support. I want to note that this works in 3.5.0, and some breaking change was introduced (or errors were made non-silent) in 4.x.

The error comes from hie giving back its capabilities on initialization, where it registers executeCommandProviders. When a second server gets spawned, this command already exists, and VSCode then complains about this.

Test.Quickcheck not found even though installed

Open the following file:

-- {-# LANGUAGE NoMonomorphismRestriction #-}
import Test.QuickCheck hiding((===))
import Control.Monad(liftM2)
import Control.Applicative((<$>),(<*>))

under Arch Linux. Then the following false positive is reported:

file: 'file:///path/to/file/Test.hs'
severity: 'Error'
message: 'Could not find module ‘Test.QuickCheck’
Use -v to see a list of the files searched for.'
at: '2,1'
source: 'ghcmod'
code: 'undefined'

QuickCheck is installed

$ pacman -Ql haskell-quickcheck
haskell-quickcheck /usr/
haskell-quickcheck /usr/lib/
haskell-quickcheck /usr/lib/ghc-8.2.2/
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/All.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Arbitrary.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Exception.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Function.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Gen.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Gen/
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Gen/Unsafe.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Modifiers.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Monadic.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Poly.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Property.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Random.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/State.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Test.dyn_hi
haskell-quickcheck /usr/lib/ghc-8.2.2/site-local/QuickCheck-2.10.1/Test/QuickCheck/Text.dyn_hi
haskell-quickcheck /usr/lib/libHSQuickCheck-2.10.1-pyTUKjDV2C3TaEubSGdV9-ghc8.2.2.so
haskell-quickcheck /usr/share/
haskell-quickcheck /usr/share/doc/
haskell-quickcheck /usr/share/doc/haskell-quickcheck/
haskell-quickcheck /usr/share/haskell/
haskell-quickcheck /usr/share/haskell/register/
haskell-quickcheck /usr/share/haskell/register/haskell-quickcheck.sh
haskell-quickcheck /usr/share/haskell/unregister/
haskell-quickcheck /usr/share/haskell/unregister/haskell-quickcheck.sh
haskell-quickcheck /usr/share/licenses/
haskell-quickcheck /usr/share/licenses/haskell-quickcheck/
haskell-quickcheck /usr/share/licenses/haskell-quickcheck/LICENSE

Add option to disable `brittany`

This extension is extremely nice and works perfectly out of the box, with one small issue, which is a matter of preference and not a bug. brittany works, but it seems extremely tame and mostly leaves my code unchanged. As a front end developer by day, I am used to the luxury of prettier, which parses the code into an AST and the reformats it aggressively. The closest thing in Haskell land appears to be hindent. It takes the following line

data Bull = Fools | Twoo deriving (Eq, Show)

and reformats it to

data Bull
    = Fools
    | Twoo
    deriving (Eq, Show)

whereas brittany doesn't change the line.

Now I understand that not everyone will want that, but since VSC does not support choosing from among multiple formatters it is up to each individual formatter/extension to offer configuration options to disable the formatter/extension. See these issues and specifically

We have always recommended extensions to either ship more fine-grained, e.g. have a separate formatter extension (and let the user decide by installing/uninstalling) or to add an option to enable/disable their formatter (more commonly used).

Command to restart hie

Due to some reason (probably all the way down in the GHC API) pretty much every Haskell IDE tool consumes a ton of memory and the amount usually increases with use. I currently solve this by monitoring memory usage and restarting VS Code when I see it's taking up too much. The problem is that this kills terminal sessions in the editor.

I'd like to be able to restart just the hie backend.

VsCode under OSX - hie not working

Hi,

I would like to help debug vscode-hie-server under osx.

The behaviour I observe is that vscode/hie seems to work correctly, for example by detecting hlint issues, only on the first haskell file that it opens.

Afterwards, when I hover on some symbol or some hlint issue I see a 'Loading' message and nothing happens. Also code formatting does not seem to do anything.

I have installed the latest hie and vscode-hie-server from github.

I have modified hie-vscode.sh to run hie in log writing mode:
hie --lsp -d -l /tmp/hie.log | tee /tmp/hie-wire.log

I can see by the hie.log that hie continues to receive commands but the output in hie-wire.log stops shortly after startup.

The log files:
hie.log
hie-wire.log

Doesn't start hie in project root

I am using this extension for a stack project. Autocomplete wasn't working so I started looking into it.

In the output window for the extension, I saw this

Launching HIE for project located at /home/dhruv

This is my home directory. Is this expected behaviour? I expected it to start HIE with the project root.

Now I think about it, HIE might have changed its default behaviour from picking up current directory as project to home directory.

Anyway, I changed this line in ~/.vscode/extensions/alanz.vscode-hie-server-0.0.8

# Run directly
hie --lsp $@

to

hie --lsp -r . $@

And it started working again.

Here's the output of hie --version on my machine.

Version 0.1.0.0, Git revision 4f2173963b14cb7603bc0c1ce731dc07ac1b7feb (1183 commits) x86_64 ghc-8.2.2

"languageServerHaskell.trace.server": "verbose" setting does not seem to work

As I understand, adding "languageServerHaskell.trace.server": "verbose" to the user settings in VSCode is supposed to make a new drop-down option available in the View -> Output pane, which displays the communication happening between VSCode and the hie server.

However it appears broken: the option doesn't appear for me. (update: it also may appear, but only say "Using hoogle db at: /Users/nickolay/.hoogle/default-haskell-5.0.17.hoo" instead of listing the detailed messages exchanged.)

Judging from this and the most recent version of that code, the setting inspected is ${clientId}.trace.server

If I change the first parameter here to new LanguageClient("languageServerHaskell", I can see the "Haskell HIE (...)" option.

BTW: why not advertise this setting more (maybe add a troubleshooting section of the README)?

Hoogle version conflict leads to crash of type information feature

There is some mismatch of hoogle versoins at my machine, and that leads to crash of type info popups.
When I open project with vs code and hoover over 3rd party types, popups work fine. But when I hoover over my type, the error happens, and I get Loading.. popup even for types that worked normally before that error.

Expected Behavior

If something goes wrong with one hoogle database, it is still possible to see type information provided by valid ones.

Actual Behavior

After I hoover over my function, type info feature crashes, and I cant see info about any function. It doesnt work even with types that were OK before the crash. Extension output:

hie: The Hoogle file /home/mitutee/Programming/my/project-management-tool/server/.stack-work/hoogle/x86_64-linux/lts-10.3/8.2.2/database.hoo is the wrong version or format.
Expected: HOOGLE-5.0.16
Got     : HOOGLE-5.0.14
CallStack (from HasCallStack):
  error, called at src/General/Store.hs:177:13 in hoogle-5.0.16-9nJOEzrw9JECpz50DooZQ3:General.Store
CallStack (from HasCallStack):
  error, called at src/General/Util.hs:235:66 in hoogle-5.0.16-9nJOEzrw9JECpz50DooZQ3:General.Util

Conflict with Vim extension on NixOS

Running vscode-hie-server with Vim makes impossible to edit files. E.g. it is not possible to move using H J K L, change mode other to NORMAL, it looks like all keyboard input is ignored. Disabling Vim plugin restores normal behaviour.

Autocompletion doesn't work at all, with cabal-helper-wrapper related errors

2018-02-28 11:25:30.079606543 [ThreadId 4] - Setting home directory:/home/marcin
2018-02-28 11:25:30.08072305 [ThreadId 4] - run entered for HIE Version 0.1.0.0, Git revision dd262b8283b3584d9d106bc842eae894826495ca (1205 commits) x86_64 ghc-8.2.2
2018-02-28 11:25:30.081598744 [ThreadId 4] - Current directory:/home/marcin
hie: Could not find $libexecdir/cabal-helper-wrapper

If you are a cabal-helper developer you can set the environment variable
`cabal_helper_libexecdir' to override $libexecdir[1]. The following will
work in the cabal-helper source tree:

    $ export cabal_helper_libexecdir=$PWD/dist/build/cabal-helper-wrapper

[1]: /home/marcin/.cache/pacaur/haskell-ide-engine-git/src/haskell-ide-engine/.stack-work/install/x86_64-linux-tinfo6-nopie/nightly-2018-02-26/8.2.2/libexec/x86_64-linux-ghc-8.2.2/cabal-helper-0.8.0.2

If you don't know what I'm talking about something went wrong with your
installation. Please report this problem here:

    https://github.com/DanielG/cabal-helper/issues

I installed haskell-ide-engine-git from AUR (Arch Linux). I can't find cabal-helper-wrapper anywhere in my FS.

Even if something went wrong in my setup, maybe vscode-hie-server could make a GUI warning that something went wrong?

Error flickering.

Errors, warnings, tips etc are not displayed, nor is anything written into output.

When I type a letter or save a file, i can see them for a millisecond. Thus when typing, I can see the errors flicker, but once I stop, they disappear again.

`Go to Definition` and `Peek Definition` are not working properly when definition is found inside the current module

First, congratulations on the excellent job with this extension and the engine. Great amount of features and real fast performance! Cheers!

I noticed a couple of issues with extensions tho.

When you try to navigate or peak the definition of a function defined inside the same module it peaks or navigates a to a source file with the same content but in a different location like for example: /private/var/folders/c3/stw488g51wncmp9g4d4wdjnm0000gn/T/ghc-mod63671/GADT16807282475249.hs.

I'm not sure how the extension works internally but I'd guess that file acts as some kind of cache. The main issue here is that modying that file won't reflect the changes on the original file, obviously. Also, the issue doesn't happen if the definition lies on another module file. It appeared to be related somehow with ghc-mod(based on the cache file path) so I tried to reproduce it with and without ghc-mod on my path and it persisted. Anyway, it seems like the engine actually shares some code with ghc-mod project so, that seems reasonable.

As additional information, I'm on macOS 10.13 High Sierra and I tried with two different resolvers: lts-8.15 and lts-9.0. There is no output for the Haskell Language Server while performing the Go to Definition and Peek Definition. However, I noticed this output when the extension loaded:

[Error - 3:08:09 PM] haskell-lsp:Got setTraceNotification ignoring
[Error - 3:08:09 PM] haskell-lsp:no handler for. Object (fromList [("jsonrpc",String "2.0"),("params",Object (fromList [("settings",Object (fromList [("languageServerHaskell",Object (fromList [("maxNumberOfProblems",Number 100.0)]))]))])),("method",String "workspace/didChangeConfiguration")])

It seems totally unrelated with the current issue but perhaps it helps. Let me know if you need anything from me so I can help you unravel this.

HIE confused about project modules

I have a simple project demonstrating what appears to be a bug.

The project has 2 modules Lib1 and Lib2, the latter importing the former. Upon opening Lib2.hs in vscode, I get this error popup:

Got error while processing diagnostics: These modules are needed for compilation but not listed in your .cabal file's other-modules: Lib1

If I dismiss it, I can continue working on the file, but it reappears whenever I make a change.

I don't know whether this is a bug with the frontend (vscode-hie-server) or backend (haskell-ide-engine). I don't know of a way to elicit more helpful diagnostics. All I can see is that some hie --lsp process is running, apparently automatically spawned from vscode, and I can't examine its stdout or make it log somewhere. So, the other issue is the apparent lack of facilities in the vscode extension to expose diagnostics and logging to enable people to make more useful bug reports. Should I file an issue for that?

The hie I'm using is the latest from HEAD but with stack.yaml changed to use nightly-2017-12-27 and allower-newer: true so that I can use it with GHC 8.2.2.

usage in a nix project?

There are some notes in the documentation about using the hie wrappers to get support in nix projects, is this possible?

I've currently installed hie-nix into my project environment (I can run the hie sever from my nix-shell) and I have the following wrappers in my vscode configuration.

    "languageServerHaskell.useCustomHieWrapper": true,
    "languageServerHaskell.useCustomHieWrapperPath": "${workspaceFolder}/backend/hie.sh"

where backend/hie.sh is:

eval "nix-shell -A backend.env --run 'hie-8.0 --lsp -d -r .'"

But it looks like this doesn't work for vscode-hie-server

[Error - 10:01:51 AM] Starting client failed
Error: spawn EACCES
	at exports._errnoException (util.js:1050:11)
	at ChildProcess.spawn (internal/child_process.js:319:11)
	at Object.exports.spawn (child_process.js:390:9)
	at _getServerWorkingDir.then.serverWorkingDir (... alanz.vscode-hie-server-0.0.16/node_modules/vscode-languageclient/lib/main.js:346:40)
	at <anonymous>

can anyone advise?

Server fails with new version

Current master fails with this error:

hie: Must call withStdoutLogging or withStderrLogging
CallStack (from HasCallStack):
  error, called at ./Haskell/Ide/Engine/MonadFunctions.hs:73:15 in hie-plugin-api-0.1.0.0-FstzkDwS3yHKVLg2PCWqHZ:Haskell.Ide.Engine.MonadFunctions
[Info  - 4:55:49 PM] Connection to server got closed. Server will restart.
[Info  - 4:55:49 PM] Connection to server got closed. Server will restart.
hie: Must call withStdoutLogging or withStderrLogging
CallStack (from HasCallStack):
  error, called at ./Haskell/Ide/Engine/MonadFunctions.hs:73:15 in hie-plugin-api-0.1.0.0-FstzkDwS3yHKVLg2PCWqHZ:Haskell.Ide.Engine.MonadFunctions
hie: Must call withStdoutLogging or withStderrLogging
CallStack (from HasCallStack):
  error, called at ./Haskell/Ide/Engine/MonadFunctions.hs:73:15 in hie-plugin-api-0.1.0.0-FstzkDwS3yHKVLg2PCWqHZ:Haskell.Ide.Engine.MonadFunctions
[Info  - 4:55:49 PM] Connection to server got closed. Server will restart.
hie: Must call withStdoutLogging or withStderrLogging
CallStack (from HasCallStack):
  error, called at ./Haskell/Ide/Engine/MonadFunctions.hs:73:15 in hie-plugin-api-0.1.0.0-FstzkDwS3yHKVLg2PCWqHZ:Haskell.Ide.Engine.MonadFunctions
[Info  - 4:55:49 PM] Connection to server got closed. Server will restart.
hie: Must call withStdoutLogging or withStderrLogging
CallStack (from HasCallStack):
  error, called at ./Haskell/Ide/Engine/MonadFunctions.hs:73:15 in hie-plugin-api-0.1.0.0-FstzkDwS3yHKVLg2PCWqHZ:Haskell.Ide.Engine.MonadFunctions
[Error - 4:55:49 PM] Connection to server got closed. Server will not be restarted.

HIE seems to be not working although the logs says it's working

I just installed HIE by cloning its repo and stack install it. I also put the path for starting HIE in the custom wrapper settings:

"languageServerHaskell.useCustomHieWrapper": true,
"languageServerHaskell.useCustomHieWrapperPath": "~/.local/bin/hie",

Opening a Haskell file shows in the output in VSCode that HIE started:

2018-04-05 08:37:18.748998 [ThreadId 4] - run entered for HIE Version 0.1.0.0, Git revision f707b3d12f8b54d7ebf9c32363b2b1a8bd04686d (1262 commits) x86_64 ghc-8.2.2
2018-04-05 08:37:18.752067 [ThreadId 4] - Current directory:/Users/sharno/projects/rogue

But all I get in VSCode is just syntax highlighting (from Haskell Syntax Highlighting extension) but nothing from Haskell Language Server extension, (no types on hover or autocomplete or anything, as if it's not there)
Did I miss something in configuration?

HLint suggestions disappear

hie --version
Version 0.1.0.0, Git revision f526f9761dff62990befaf94ea8a21443d7463a1 (1223 commits) x86_64 ghc-8.2.2

Windows 10

vsc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.