Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

bad module error handling with hlint enabled #1782

Open
mduerig opened this issue May 31, 2020 · 4 comments
Open

bad module error handling with hlint enabled #1782

mduerig opened this issue May 31, 2020 · 4 comments

Comments

@mduerig
Copy link

mduerig commented May 31, 2020

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
Copy link
Author

mduerig commented May 31, 2020

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

@jneira
Copy link
Member

jneira commented Jun 9, 2020

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 jneira self-assigned this Jun 9, 2020
@jneira
Copy link
Member

jneira commented Jun 9, 2020

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 jneira changed the title VSCode IDE support broken after stack upgrade bad module error handling with hlint enabled Jun 9, 2020
@mduerig
Copy link
Author

mduerig commented Jun 10, 2020

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

@jneira jneira removed their assignment Sep 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants