commercialhaskell / stack-ide

Stack-based JSON interface to ide-backend
98 stars 23 forks source link

Bug? Stack-ide cannot see an instance declared in another module #59

Closed drwebb closed 8 years ago

drwebb commented 9 years ago

I have two modules, one, call it "Foo" that is declaring an instance of ToJSON for a datatype, the other module "Bar" is using the encode method. For some strange reason, stack-mode is complaining that I haven't declared the ToJSON instance by showing an error in "Bar", yet stack when run from the cli it compiles as I expect. When I copy-paste the instance declaration from "Foo" to "Bar" it compiles in stack-mode, but obviously stack from the cli reports a duplicate instance declaration.

bitemyapp commented 9 years ago

We've been getting this too (at least a few weeks), I end up running stack clean and then rebuilding/restarting the REPL to fix it.

drwebb commented 9 years ago

I haven't been able to clear up the problem, even by doing a stack clean and restarting emacs.

bitemyapp commented 9 years ago

@drwebb my problem was with plain old stack rather than the IDE specifically.

drwebb commented 9 years ago

In another module in the same project, I get another possibly similar error (at least it is to do with instances no being resolved correctly):

    No instance for (Y.FromJSON SphinxPort)
      arising from a use of ‘Y.decode’
    In the third argument of ‘maybe’, namely ‘(Y.decode s)’
    In the second argument of ‘($)’, namely
      ‘maybe
         (error $ Failed to load and parse:  ++ path) id (Y.decode s)’
    In a stmt of a 'do' block:
      return
      $ maybe
          (error $ Failed to load and parse:  ++ path) id (Y.decode s)

The module looks like

...
import qualified Data.Yaml as Y
import Data.Aeson

instance FromJSON SphinxPort where
...

a normal stack build works fine.

mgsloan commented 9 years ago

Here's an attempt at a minimal repo, but I'm not having issues with it: https://github.com/mgsloan/issue-59-stack-ide

I'll keep my eye out for such issues.

drwebb commented 9 years ago

@mgsloan: FWIW I could not duplicate in a minimal repo either.

drwebb commented 8 years ago

I'm going to close this issue, seeing I have not been able to reproduce. The problem has cleared up in the project that was giving me problems.