7

I can stack build a project from the command line but when I try C-c C-l in emacs (with (custom-set-variables '(haskell-process-type 'stack-ghci))) I get an error that all the package modules I import can't be found.

/home/amcp011/bec/amcp011/accelerate/gpe/src/Numeric/GPE/Utils.hs:30:1: error:
    Failed to load interface for ‘Data.Array.Accelerate’
    Locations searched:
      Data/Array/Accelerate.hs
      Data/Array/Accelerate.lhs
      Data/Array/Accelerate.hsig
      Data/Array/Accelerate.lhsig
      /home/amcp011/bec/amcp011/accelerate/gpe/src/Data/Array/Accelerate.hs
      /home/amcp011/bec/amcp011/accelerate/gpe/src/Data/Array/Accelerate.lhs
      /home/amcp011/bec/amcp011/accelerate/gpe/src/Data/Array/Accelerate.hsig
      /home/amcp011/bec/amcp011/accelerate/gpe/src/Data/Array/Accelerate.lhsig

gpe.cabal:

build-depends:       base >= 4.7 && < 5
                   , bytestring
                   , bytestring-conversion
                   , mtl
                   , time
                   , filepath
                   , directory
                   , accelerate
                   , accelerate-io

stack.yaml:

extra-deps: [accelerate-1.0.0.0
            ,accelerate-io-1.0.0.0
            ]
HTNW
  • 27,182
  • 1
  • 32
  • 60
vivian
  • 1,434
  • 1
  • 10
  • 13
  • 1
    Do you happen to have a public link to this project? It is tough to debug without an example... – Alec Aug 19 '17 at 02:07
  • @Alec: https://github.com/amcphail/gpe It is not finished, I have uploaded in response to your comment. I am in the development stage where it is helpful to load files in emacs. – vivian Aug 21 '17 at 04:50

1 Answers1

5

I was able to compile your project with stack build (of course, after installing a few system wide dependencies like llvm, cuda, fftw3 etc.) and load it fine with C-c C-l in emacs.

Here is the minimal emacs config that worked for me:

(defun haskell-mode-setup ()
  (setq haskell-process-type 'stack-ghci))

(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(add-hook 'haskell-mode-hook 'haskell-mode-setup)

The only ways I was able to replicate the issue you are having was with inf-haskell-mode, instead of interactive-haskell-mode, as well as simply by setting (setq haskell-process-type 'ghci). So, it is possible that emacs doesn't find stack.

I'd recommend trying to let haskell-mode know where stack is, in case that it is installed in a non-common location: (setq haskell-process-path-stack "/path/to/stack").

Alternatively, I've solved a few issues in the past related to $PATH environment variable being not the same that is set for the current user, but the one that is used system wide. Simply install exec-path-from-shell emacs package and add (exec-path-from-shell-initialize) to the ~/.emacs.

Also, if you haven't done it yet, inspecting haskell-mode log could prove being useful. Add (setq haskell-process-log t) to haskell-mode-setup, which will result in an extra buffer with the log.

Notes:

  • In order to compile your package, I had to remove few lines from stack.yaml, namely ones that include local dirs /home/amcp011/local/, which are not included in the repo and use my system installed gcc instead of one from RHEL6.3.
  • If you use some other emacs packages besides haskell-mode, they might be the cause of the problem as well. I've tested it with intero and flycheck without any problems.
  • Try upgrading to newest stack upgrade and haskell-mode, maybe that will help. I've tested with stack-1.5.1 and haskell-mode-20170824.1124 on emacs-25.2.2
lehins
  • 9,642
  • 2
  • 35
  • 49