haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 211 forks source link

Emacs: flymake is not able to use hie as backend #1648

Open schnecki opened 4 years ago

schnecki commented 4 years ago

I have following cabal file, where I left out uninteresting parts:

cabal-version: 1.12
name:           app
version:        0.1.0
build-type:     Simple

library
  exposed-modules:
      Application
      DataTypes
      ...
  hs-source-dirs:
      src
      shared
  default-extensions: NoImplicitPrelude, ViewPatterns
  build-depends:
      aeson >=1.4 && <1.5
      ...
    , zip
  ghc-options: -Wall -fwarn-tabs -O2
  default-language: Haskell2010

executable devboardserver
  main-is: main.hs
  other-modules:
      DevelMain
      Paths_devboardserver
  hs-source-dirs:
      app
  default-extensions: NoImplicitPrelude, ViewPatterns
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      aeson >=1.4 && <1.5
      ...
    , zip
  default-language: Haskell2010

Note the hs-soure-dirs entry of the library, it states two folders: src as usual, and shared in the project root directory. However files under shared, like shared/DataTypes.hs are not found, i.e. included when building. I could not find a way to configure multiple paths that are not sub-directories of src. Is there an intended way to do so, as it does not work automatically?

jneira commented 4 years ago

Hi, thanks for reporting

However files under shared, like shared/DataTypes.hs are not found, i.e. included when building

If you try to build the project from the console using stack or cabal, does it throw any error? or only when opened with hie?

schnecki commented 4 years ago

Hi, It only throws an error in hie, or actually more precisely, as I figured out now, it only throws the error for flycheck, i.e. the emacs way of syntax checking. However, I figured if I disable the hie the same error is reported by standard flychecking. Thus, I suspect either hie just uses the flycheck output without, or incorrect arguments are passed to it.

jneira commented 4 years ago

I've setup a similar project and in vscode all looks fine. What is the error message? Not sure if i fully understand so just in case:

jneira commented 4 years ago

I've loaded the same project in emacs and i am observing that flymake is not finding the DataTypes module but it does not find any module from external dependencies but the included in base neither. So if you import modules from aeson f.e., does flycheck complain about them too?

I dont see errors in *Flymake log*, or *hie:stderr*

schnecki commented 4 years ago

To your two question: Yes exactly. And furthermore, as it does not use the settings of the stack.yaml / cabal file, it also ignores the entry

default-extensions: NoImplicitPrelude, ViewPatterns

Meanwhile I have added the the shared path to flycheck-ghc-search-path (see https://www.flycheck.org/en/latest/languages.html#syntax-checker-haskell-stack-ghc), which solves the first problem, but of course not the one with the default extensions settings.

I don't have errors in hie:stderr either, except for this one (which I suppose can be neglected):

hie-8.6.5: loadObj: /tmp/ghc16809_0/ghc_63.o: file doesn't exist

So I think the problem seems to be exactly what you stated: So flycheck is not using hie

jneira commented 4 years ago

I've just observed that flymake status is: Wait[0 0] and on hover it shows: Waiting for 1 running backend and the errors are shown before hie ends loading the project so definitely the problem seems to be the communication between both components (flymake -> hie) Maybe @alanz could help us cause i think it is using hie with emacs.

jneira commented 4 years ago

@schnecki i hope you dont mind the renaming of the issue, i think it is more accurate given our last checks. I've labeled as "upstream" cause i think it is probable that the fix would not be in hie itself.

schnecki commented 4 years ago

@jneira np at all But I just figured that fie is using flymake and not flycheck as I supposed.

EDIT: You might want to integrate this: https://github.com/chrisdone/flycheck-stack It is very lightweight and works quite well. Is there a way to disable flymake in hie completely?