4

I'm currently evaluating Haskero in Visual Studio Code as an alternative Haskell editor instead of Atom with Atom-Haskell. So far, Haskero seems promising, but I miss the compiler warnings I'd usually get from Atom-Haskell.

As a way to illustrate the problem, consider this simple repro:

Steps to reproduce

  1. Open Visual Studio Code with Haskero already installed
  2. Add a new Haskell file: Repro.hs
  3. Add the following content to the file
  4. Press Save

File contents:

module Repro where

foo :: Maybe a -> a
foo (Just x) = x

Expected behaviour

The editor should give a warning to the effect of:

Pattern match(es) are non-exhaustive
In an equation for `foo': Patterns not matched: Nothing

Atom-Haskell does this.

Actual behaviour

Nothing happens. The Problems view just states that:

No problems have been detected in the workspace so far.

More details

The above steps to reproduce are the simplest ones I could think of, but I see the same (lack of) behaviour when I create a full Stack project and make sure that I've run stack build intero in the root of my project directory.

My environment is:

  • Windows 10 Pro x64
  • Stack version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0
  • Visual Studio Code version 1.20.0
  • Haskero version 1.3.1
  • Atom version 1.23.3 x64
  • language-haskell version 1.17.3
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
  • Are warnings enabled? I just tried running intero, and I had to turn them on editing the cabal file. I guess `stack.yaml` and an `OPTIONS` pragma should work too. – chi Feb 13 '18 at 16:26
  • @chi In one of my 'real' Stack projects, I've tried editing the `.cabal` file like this: `ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall` (I added `-Wall`). This definitely causes `stack build` or `stack test` to display the desired warning, but Haskero doesn't, even after a restart... – Mark Seemann Feb 13 '18 at 16:30
  • If I recall correctly from when I tried Haskero years ago, you need to install Intero separately. Damned if I can remember the right way to do that though. If you commit an error (rather than a warning) do you get an error from Haskero? – Benjamin Hodgson Feb 14 '18 at 00:39
  • @BenjaminHodgson According to the Haskero documentation, one has to run `stack build intero` in the project folder, which I've also done in my 'actual' projects (I just didn't include this above, as it doesn't seem to be required in order to reproduce the issue). If I write invalid code, Haskero immediately reports this. – Mark Seemann Feb 14 '18 at 06:59

1 Answers1

2

It looks like you have to tell Haskero to make any warning into a fatal error (note the -Werror flag):

"haskero.intero.ghciOptions": [
    "-Wall",
    "-Werror"
]

enter image description here


However, I can't really understand why we would have to do this, since this works out of the box:

stack ghci --with-ghc intero "--ghci-options=-Wall" --no-build --no-load

enter image description here

That seems to be the way Haskero launches Intero in Visual Studio Code, and in GHCi I can see the warning without passing -Werror...


Out of curiosity, I've tried the same with hsdev 0.3.1.2, and Sublime Haskell 91e0d29, and seems to be working straight out of the box:

enter image description here

Hope that helps.

Nikos Baxevanis
  • 10,868
  • 2
  • 46
  • 80
  • I would suggest to also keep an eye on https://langserver.org/, and [haskell-ide-engine](https://github.com/haskell/haskell-ide-engine) in particular, and if that doesn't work out of the box either, I would give [hsdev](https://github.com/mvoidex/hsdev) 0.3.1.2 a shot. – Nikos Baxevanis Feb 15 '18 at 05:44
  • I can confirm that adding `-Werror` to my options behaves in the way described here. I haven't tried the Sublime Haskell option yet, as I must admit that I'm beginning to experience Haskell tool stack fatigue... – Mark Seemann Feb 15 '18 at 07:06
  • That's nothing compared to string interpolation in Haskell ;) – Nikos Baxevanis Feb 15 '18 at 14:09
  • @MarkSeemann Do you still have issue(s) with Haskero or those are fixed in later versions of it? (It looks like you currently [use](https://stackoverflow.com/q/52754334/467754) Haskero.) – Nikos Baxevanis Oct 11 '18 at 10:30
  • Those issues remain. I don't think Haskero has been updated in more than a year, but I also haven't found anything that works better... – Mark Seemann Oct 11 '18 at 10:49
  • Pretty much same here. Eventually, I realized that the only reliable Haskell 'IDE' can be the command-line. One window edits text. One window displays type errors using `ghcid`. One window tests the Haskell code I write in a REPL. In addition to those, for an IDE-like experience, I would try [haskell-code-explorer](https://github.com/alexwl/haskell-code-explorer), and [debug](https://github.com/ndmitchell/debug) (both are on my list of things to try). – Nikos Baxevanis Oct 12 '18 at 04:47