SublimeHaskell
SublimeHaskell copied to clipboard
How to supress warnings for on-save build?
I want SublimeHaskell to check my files when I do a save, but there are a lot of things that the linter grabs up, for example, a top-level declaration without a type signature, or shadowing a variable, that I often don't care about. Then, when there is a legitimate error, like a type error, it's hidden in a sea of trivial warnings which makes it more convenient to simply compile it in GHC/i to see the error rather than looking at SublimeHaskell's output. Further, it's kind of annoying to have the console pop up every time I save, much less with Build FAILED, especially if there aren't any errors.
I was able to disable the checking entirely with "enable_ghc_mod": false, but I don't want to turn off everything. How can I choose which warnings to disable, or failing that, simply kill off the warnings and only have it show errors?
Looking through the source, I can see that these things are being called in autobuild.py, but I can only trace it as far as view.window().run_command('sublime_haskell_ghc_mod_check_and_lint'), and I don't know how that works, since a text search for sublime_haskell_ghc_mod_check_and_lint only returns 2 results, neither of which are a definition of that command.
are a lot of things that the linter grabs up
Just to not to confuse the two: It's not the linter (like our hlint support), it's just ghc warnings.
Anyway, that is not what you asked.
How can I choose which warnings to disable, or failing that, simply kill off the warnings and only have it show errors?
Have you seen the auto_build_mode in the settings?
// How to build the cabal project in order to obtain error messages.
// This option exists because `cabal build` is slow and cannot re-print
// warnings of already compiled modules.
// (Also see https://github.com/haskell/cabal/issues/1179, cabal 1.16).
//
// Possible values:
// - "normal"
// Uses a full `cabal build`, generating object files and binaries.
// If this takes too long for you, look at the other options.
// - "normal-then-warnings"
// Like "normal", but afterwards also collects project-wide warnings with
// `cabal build --ghc-options="-fforce-recomp -Wall -fno-code"`
// (this recompiles everything, but skips code generation for speed).
// - "typecheck"
// Performs a type check of the whole project, trying to not do any more
// than that in order to give faster feedback (that "normal").
// Currently uses `cabal build --ghc-options="-c"` to skip linking.
// - "typecheck-then-warnings"
// Like "typecheck", but afterwards collects warnings like
// "normal-then-warnings".
//
// Please note that it is currently impossible to properly use a `-fno-code`
// build on a cabal project that links a shared library; it errors too early.
// (https://github.com/haskell/cabal/issues/1176, cabal 1.16).
"auto_build_mode": "normal-then-warnings",
I think "auto_build_mode": "normal", is what you are looking for.
Could you check if that is it?
Ah, thanks for the clarification. Hmm, unfortunately it didn't help. I've so far tried it on normal and typecheck, to no effect.
I don't know how that works, since a text search for sublime_haskell_ghc_mod_check_and_lint only returns 2 results, neither of which are a definition of that command
SublimeText has mixed name convention for commands. Command named FooBar[Command] in python will be seen as foo_bar in SublimeText. So in your case there is SublimeHaskellGhcModCheckAndLint class at ghcmod.py:43
Hmm, unfortunately it didn't help.
Ah, I think the reason is that this setting is only for building and getting error messages/warnings with cabal. You only want to use ghc-mod, without cabal, is that correct?
In that case, adding a setting that would control the warning level for ghc-mod would be a useful addition!
You can prevent these warnings by putting OPTIONS_GHC pragmas at the top of your source files.
E.g. {-# OPTIONS_GHC -fno-warn-type-defaults #-}.
Or, you can add the following to your SublimeHaskell.sublime-settings config:
"ghc_opts": ["-fno-warn-type-defaults"],