Warning for `incomplete-patterns` in visual studio code for haskell

Viewed 128

How do you get the visual studio haskell extension to warn about incomplete-patterns ?

I don't see such a settings on VS code side. haskell-language-server has a pedantic plugin, disabled by default. Which I imagine can spot incomplete-patterns, just like stack build --pedantic can when building.

#!/usr/bin/env stack
-- stack --resolver lts-17.10 script

module SOQuestionIncomplete0 where

data Sum s t a = Inl (s a) | Inr (t a)

injs :: Sum s t a -> t a
injs (Inr ta) = ta -- incomplete, no warning

-- >>>   injs (Inl [1 :: Int]) :: [Int]
-- /src/SOQuestionIncomplete0.hs:9:1-18: Non-exhaustive patterns in function injs

main :: IO ()
main = do
  let a = injs (Inl [1 :: Int]) :: [Int]
  putStrLn $ "Hello, World!" ++ show a
1 Answers

The most favoured approach is always to add flags such as this to the ghc-options in your cabal or stack file.

If you've got a project with no cabal file, add a file named hie.yaml to the project directory, with the following contents:

cradle:
  direct:
    arguments: ["-Wincomplete-patterns"]
Related