0

UPDATE: clarified that this is on Mac OS X

I'm using Emacs Prelude (which uses haskell-mode) on Mac OS X and I've created a project with stack new hello.

The project it generates is like this:

  • hello:
    • LICENSE
    • Setup.hs
    • hello.cabal
    • stack.cabal
    • app:
      • Main.hs
    • src:
      • Lib.hs
    • test:
      • Spec.hs

If I open Main.hs in Emacs it shows this:

module Main where

import Lib

main :: IO ()
main = someFunc

But Lib is underlined as an error and placing my caret there shows this:

Could not find module 'Lib'
Use -v to see a list of the files searched for.

How do you get Emacs haskell-mode to find modules in other hs-source-dirs?

Alain O'Dea
  • 21,033
  • 1
  • 58
  • 84
  • 1
    does `C-c C-l` load it into the REPL? Is `'haskell-process-type` set to `auto`? – Random Dev Mar 29 '16 at 19:56
  • 1
    btw: maybe you should update to a current `haskell-mode` - not sure when `stack`-support was included but maybe you got an older version - also: why is there a `stack.cabal`? It's `stack.yaml` right? – Random Dev Mar 29 '16 at 19:57

1 Answers1

0

The greatest horror is that I fixed this by rebooting.

I appear to have triggered it by breaking the path to Stack. The path changed from my original manual install to ~/Applications/bin/stack to ~/.local/bin/stack. I knew that had changed so I closed and relaunched Emacs, but the problem persisted.

Rebooting fixed it. This brings me sadness. I imagine logging out might have worked just as well.

Alain O'Dea
  • 21,033
  • 1
  • 58
  • 84
  • 1
    it was probably only your path-variable ^^ so restarting emacs (really restarting) and/or the shell you used would probably have been fine too (check with `which stack`) ;) – Random Dev Mar 30 '16 at 04:06
  • @Carsten I reproduced it from scratch after. M-x getenv ENT PATH immediately showed the missing path. That was fixable by logout. Running the interactive shell needed a separate fix in .emacs `(setq exec-path (append exec-path '("/usr/local/bin")))` – Alain O'Dea Mar 30 '16 at 04:11
  • 1
    that's strange as emacs should use your existing path (maybe the order is wrong - is pointing `which stack` to the right one) - anyway the most important thing is that it's working for you again ;) – Random Dev Mar 30 '16 at 04:13
  • @Carsten Yep. It's now solid. I'm partly conflating things here as that setq step is related to the fact that I'm now using bitemyapp's .emacs and .emacs.d/ from https://github.com/bitemyapp/dotfiles. – Alain O'Dea Mar 30 '16 at 04:16