1

I recently updated Cabal to version 1.22, before installing ghc-mod so I could get some much needed error-checking in my projects.

The update didn't come without complications, ghc-mod wouldn't even run before I had added the path of the latest version of Cabal to $PATH. Upon doing so, haskell-mode started acting up, as loading the interpreter no longer greeted me with the familiar phrase "Your command is my IO", but instead appeared to be the standard GHCI. Not only that, but it didn't ask if I wanted to start a new project named haskell like it usually did prior to the change; and with that, all the glorious autocompletion was gone.

After a bit of fiddling around I learned that Emacs had trouble loading haskell-interactive-mode, being told it had something to do with haskell-mode itself, I installed it anew, and added

(require 'haskell-mode)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(eval-after-load "auto-complete"
  '(add-to-list 'ac-modes 'haskell-interactive-mode))

to my .emacs file, and suddenly the error was gone, however the problem persists, and now whenever I try loading the interpreter, Emacs will ask me to provide a path to Cabal, then the current working directoryl; after which I'll be greeted by the repl that used to enable the autocompletion.

Except... it still doesn't autocomplete. Or rather, it autocompletes whatever's in the document, but it doesn't reveal functions as I type, it doesn't show me sub-modules like it used to, it doesn't do anything at all, except auto-generate type signatures when I press C-u C-c C-t.

I really have no idea how to go by from here, and would really appreciate some help.

Electric Coffee
  • 11,733
  • 9
  • 70
  • 131
  • Put the haskell library in your `load-path` and `require` it. See the Emacs manual for how to require libraries. – Drew Jan 08 '15 at 02:22
  • @Drew I have no idea what you mean by haskell library... do you mean the ghc path, or the haskell mode path? – Electric Coffee Jan 08 '15 at 05:05
  • 1
    What version of GHC do you use? Perhaps it's this issue: https://github.com/kazu-yamamoto/ghc-mod/issues/417 - ghc-mod only works with Cabal 1.22 if you use GHC 7.10 (the format of the 'setup-config' file ghc-mod parses changed to binary). I had similar problems in Vim and went back to the last Cabal version and now ghc-mod works again. – Rüdiger Hanke Jan 08 '15 at 09:22
  • @RüdigerHanke I have GHC 7.6.3, and Cabal 1.22 – Electric Coffee Jan 08 '15 at 09:33
  • Then that could be the problem. Does ghc-mod work from the command line? Check if the file "dist/setup-config" in your cabal project is binary now. That would cause the error "[path]/dist/setup-config: hGetContents: invalid argument (invalid byte sequence)" when starting ghc-mod. As I understand it, the solution is either to upgrade to GHC 7.10 or go back to an older Cabal. – Rüdiger Hanke Jan 08 '15 at 09:49
  • What I meant was this: You are tying everything to `haskell-mode`, but nowhere do you show that you load the code that defines that mode. Put the location of **any** Lisp library that you want to load in your `load-path`, and `require` it. And especially: I meant what I said about reading the Emacs manual section about loading libraries. The information you are missing is common to all libraries and to using Emacs generally. And if you use the package manager then read the manual section about that. In sum, **ask Emacs**. – Drew Jan 08 '15 at 13:37
  • @Drew I have it loaded from the package manager, in which case I don't need to manually `require` it... at least that's what the doc says – Electric Coffee Jan 08 '15 at 15:41
  • OK, in that case, check why it was **not** loaded, because apparently it was not. Both your question title and the error `(void-function interactive-haskell-mode)` indicate that the haskell-mode code was not loaded. That is your problem, AFAICT: you do **not** "*have it loaded from the package manager*". – Drew Jan 08 '15 at 16:04
  • @Drew then it begs the question, why did the highlighting work correctly, and better yet, why was "Haskell" written as a major mode at the bottom of the buffer? Adding `(require 'haskell-mode)` does fix the error, but the autocomplete still doesn't work – Electric Coffee Jan 08 '15 at 17:13
  • In that case, your question title is incorrect/misleading and apparently `interactive-haskell-mode` is not something defined by the haskell package you installed. Your question rambles and is not very clear at this point. Please consider editing it. It sounds like your question really has to do (only?) with why autocomplete is not working, but I'm not sure. – Drew Jan 08 '15 at 17:30
  • And that would explain two things: why you got the error about `interactive-haskell-mode` and why autocomplete does not work. It is not the Haskell package that is not installed; it is the autocomplete package that is not installed. Go back and read what was written about installing the haskell package and replace it by the autocomplete package. Either install it using the pkg mgr or put it in your `load-path` and `require` it. – Drew Jan 08 '15 at 17:31
  • @Drew oh autocomplete works alright.. with other languages than haskell – Electric Coffee Jan 08 '15 at 17:44
  • You're not getting the point. Your question is not clear. And you probably need to provide more information. What is the value of `ac-modes`, for instance? If library autocomplete is loaded then `ac-modes` should have an entry for `haskell-interactive-mode`. And find out what code should have defined `haskell-interactive-mode` (apparently that code was not invoked or did not do its job). – Drew Jan 08 '15 at 17:48
  • @Drew there, re-written – Electric Coffee Jan 08 '15 at 18:52
  • Thanks. Hopefully someone will now be able to help more. Is it correct that you have both `interactive-haskell-mode` and `haskell-interactive-mode`? – Drew Jan 08 '15 at 20:48
  • @RüdigerHanke How would I go by upgrading ghc? my package manager doesn't have any newer version – Electric Coffee Jan 10 '15 at 16:39

0 Answers0