Friday, November 10, 2017

Ghcid with VS Code

Summary: New versions of Ghcid and the VS Code extension work even better together.

I've just released Ghcid v0.6.8 and the associated VS Code extension haskell-ghcid v0.2.0. Together they vastly simplify the Ghcid VS Code experience.

Ghcid reads .ghcid files

A new feature in Ghcid is that if there is a .ghcid file in the current directory it will load it as additional arguments. For example, in the Shake repo I have a .ghcid file:

-c "ghci -fno-code -ferror-spans"

Which tells ghcid to not guess at the command (e.g. using stack if you have a .stack-work) but always run ghci -fno-code -ferror-spans. This command works because I have a .ghci file which loads all the necessary files, while -fno-code speeds up compilation and -ferror-spans gives better error highlighting.

Ghcid VS Code starts ghcid

A new feature in the VS Code extension is the action Start Ghcid which starts a new ghcid terminal, writes the output to a temporary file, and uses that output to populate the Problems pane. Importantly, the extension runs ghcid with no command line arguments, so having a sensible .ghcid lets you control what it does.

The effect of these changes is that to start ghcid in VS Code is now a few key strokes, whereas before it required special flags, opening files, running commands etc.


hogetaroubig said...

> Importantly, it runs ghcid with no additional arguments, so having a sensible .ghcid file is important.

I'm not sure if I understand this sentence correctly. I think this means "VS Code extension ignores .ghcid file, so there's the case in which even if you want to pass arguments to ghcid, they won't be passed". Am I correct?

Neil Mitchell said...

@hogetaroubig: VS Code doesn't let you pass command line arguments, so the .ghcid file is essential, as that's where you can control what ghcid does. I've updated the text in the post to try and make that clearer - thanks for letting me know.

hogetaroubig said...

I understand. Thank you!

hogetaroubig said...

I'm working on translating Haskellers' blog posts into Japanese. I translated your blog posts including this recently. I'd like to share them on the Internet. Is this alright?

Neil Mitchell said...

@hogetaroubig: Certainly, I'd be delighted!

Only requirement is that you include a link to the original and acknowledge me as the author and you as the translator. I'd also suggest you comment with your translated version in the comments to my blog, so people can find it.

Kotaro Ohsugi said...
This comment has been removed by the author.
hogetaroubig said...

I'm glad to hear that!

All right, I will:)

hogetaroubig said...

Translated into Japanese:

Thank you for your awesome blog posts!