haskell-ide-engine icon indicating copy to clipboard operation
haskell-ide-engine copied to clipboard

bad module error handling with hlint enabled

Open mduerig opened this issue 4 years ago • 4 comments

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.

mduerig avatar May 31 '20 09:05 mduerig

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...

mduerig avatar May 31 '20 15:05 mduerig

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

jneira avatar Jun 09 '20 22:06 jneira

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.

jneira avatar Jun 09 '20 22:06 jneira

Thanks for confirming and providing a workaround. So far I've been hitting the "Haskell: restart HIE" action every now and then.

mduerig avatar Jun 10 '20 16:06 mduerig