haskell-ide-engine
haskell-ide-engine copied to clipboard
bad module error handling with hlint enabled
After upgrading stack to 2.3.1 yesterday Haskell support in VScode is severely broken:
-
After opening an empty project created with
stack new myproject
I see "Initializing Stack project" popping on and off in the status bar for many time until it settles. -
After I edit an Haskell file this starts all over again until finally an error indicator appears for e.g. an variable that is not in scope.
-
When I fix a problem the error indicators stick around until I close and restart VScode.
Apparently the upgrade didn't have anything to do with the problem I'm facing. It looks like HIE chokes on my code. To reproduce:
Create a new project with stack init foobar
and open with VSCode. Paste the following into src/Lib.hs
:
{-# LANGUAGE DeriveFunctor #-}
module Lib where
class ( Functor m ) => Mon m where
join :: m ( m x ) -> m x
data State s a = State ( s -> ( s, a ))
deriving Functor
instance Mon ( State s ) where
join ( State f ) = State $ \s ->
let
(ss, ( State g )) = f s
in
g ss
qqqq
This causes an error indicator to appear on the last line (qqqq
). So far so good. However, removing that line doesn't make the error indicator go away and Lib.hs
keeps marked as containing an error. Only after commenting out and in again the whole instance declaration for Mon
are things back to normal. At least until I make the next typo...
Hi! Sorry for the late response. I can reproduce the error and it is a pretty weird one. The code is totally correct. It has to be related with some weird syntax handling error in hie... investigating
Ok, i thing the error comes from hlint (the linter used by hie by default). If you turn off the extension option:
{
"languageServerHaskell.hlintOn": false
}
the problem is gone. hlint has to parse the module too and not always match the compiler parsing.
Thanks for confirming and providing a workaround. So far I've been hitting the "Haskell: restart HIE" action every now and then.