问题
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
- Open Visual Studio Code with Haskero already installed
- Add a new Haskell file:
Repro.hs
- Add the following content to the file
- 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
回答1:
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"
]
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
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:
Hope that helps.
来源:https://stackoverflow.com/questions/48770086/how-to-get-haskero-to-warn-on-non-exhaustive-pattern-matches