0
votes

Following haskell repl in emacs, I could install packages. I used MELPA stable for repository ('("melpa-stable" . "http://stable.melpa.org/packages/") t))

  • ghc
  • haskell-mode
  • flycheck
  • flycheck-haskell

I also installed the binaries with cabal.

  • cabal install ghc-mod (5.3.0.0)
  • cabal install happy (1.19.5)

Cabal version 1.22.6.0, GNU Emacs version 24.5.1 on Mac OS X 10.10.4.

The issue is that when I tried to run ghci with C-`, I have the error message.

command-execute: Autoloading failed to define function haskell-interactive-bring

With C-c C-l, I have this error message.

command-execute: Autoloading failed to define function haskell-process-load-or-reload

What might be wrong?

enter image description here

This is the Haskell related code in init.el.

;; Haskell

; http://www.mew.org/~kazu/proj/ghc-mod/en/preparation.html
(autoload 'ghc-init "ghc" nil t)
(autoload 'ghc-debug "ghc" nil t)
(add-hook 'haskell-mode-hook (lambda () (ghc-init)))
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation).

; https://github.com/serras/emacs-haskell-tutorial/blob/master/tutorial.md 
; https://stackguides.com/questions/26603649/haskell-repl-in-emacs
(let ((my-cabal-path (expand-file-name "~/Library/Haskell/bin")))
  (setenv "PATH" (concat my-cabal-path ":" (getenv "PATH")))
  (add-to-list 'exec-path my-cabal-path))
(custom-set-variables '(haskell-tags-on-save t))

(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

(eval-after-load 'haskell-mode '(progn
  (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
  (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring)
  (define-key haskell-mode-map (kbd "C-c C-n C-t") 'haskell-process-do-type)
  (define-key haskell-mode-map (kbd "C-c C-n C-i") 'haskell-process-do-info)
  (define-key haskell-mode-map (kbd "C-c C-n C-c") 'haskell-process-cabal-build)
  (define-key haskell-mode-map (kbd "C-c C-n c") 'haskell-process-cabal)))
(eval-after-load 'haskell-cabal '(progn
  (define-key haskell-cabal-mode-map (kbd "C-`") 'haskell-interactive-bring)
  (define-key haskell-cabal-mode-map (kbd "C-c C-k") 'haskell-interactive-ode-clear)
  (define-key haskell-cabal-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
  (define-key haskell-cabal-mode-map (kbd "C-c c") 'haskell-process-cabal)))

(custom-set-variables
 '(haskell-interactive-mode-hide-multi-line-errors nil)
 '(haskell-process-log t)
 '(haskell-process-type (quote cabal-repl)))

Added

In Emacs, auto completion shows that the "haskell-interactive-bring" function is available.

enter image description here

However, autoloading is failed.

enter image description here

1
Is the ghci binary somewhere in the PATH or in ~/Library/Haskell/bin? If which ghci reveals that it's somewhere else, try adding it to the path. - nickie
Check the generated autoloads file, to see in what way it does not correspond to what you expected, in particular, wrt loading the file that defines haskell-interactive-bring. The error msg is telling you that the file that defines it was not loaded. Check also for a typo in the function name. ;-) - Drew
@nickie: ghci is in /usr/bin, and I added the path with (add-to-list 'exec-path "/usr/bin") in init.el just in case. The results are the same, though. - prosseek
@Drew: Could you elaborate where the generated autoloads file is located? The file name is correct, as is blinded to C-` in the setup file. I corrected the title though. - prosseek
I'm no expert on package.el, but I think you might find a file YOUR-PACKAGE-autoloads.el, which was generated when you installed package YOUR-PACKAGE. In any case, one place to start is to find out what file haskell-interactive-bring is defined in. - Drew

1 Answers

2
votes

The issue was that I have "haskell.el" that stores all the haskell related configuration setup. This has caused some conflict so that the "haskell.el" in the ELPA/haskell... package unable to properly loaded.

When I renamed my "haskell.el" to "haskell_config.el", everything seems to be working fine.