Haskell repl in emacs

Hi, I am starting with haskell and trying to configure emacs to develop it.

I have haskell-mod and ghc-mod last in emacs 24.3.1 . GHC 7.6.3

I created a haskell first.hs file and when I do Cc Cl it asks:

 start a new project named haskell ? y or n 

my haskell directory name. I press y

 Set the cabal directory 

I tried with ~ / .cabal and my current directory called haskell

 Set the current directory 

Just hit enter as it has haskell directory

Error messages are displayed here:

 haskell-process-start: cl-ecase failed: cabal-rep, (ghci quote cabal-repl quote cabal-ghci quote cabal-dev quote) 

How can I get an answer?

I read that I may need to downgrade ghc in order for it to work. This is a good decision?

Solution :

I had several custom-set-variables in init.el and this led to this problem.

+7
emacs haskell read-eval-print-loop haskell-mode
source share
1 answer

UPDATE 2017

now that we have Intero I would suggest you try Intero / Stack - it works pretty well.

With it, my configuration is reduced even lower:

 ;; ---------------------------------------------------------------------- ;; HASKELL (require 'haskell-mode) (require 'intero) (add-hook 'haskell-mode-hook 'intero-mode) (require 'flycheck) (setq flycheck-check-syntax-automatically '(save new-line)) (flycheck-add-next-checker 'intero '(warning . haskell-hlint)) 

Regarding REPL , you basically just upload the file and then Cc Cl to repl (you can always switch between two windows with Cc Cz and you can clear the relay with Cc Ck (when inside).

The only drawback is that Intero is usually installed locally in your project, so the first start in a new project will take some time for Intero to load / compile / download, but that doesn't really matter and you get a lot.


UPDATE

Now that the stack works and works fine, I would recommend setting haskell-process-type to auto and possibly installing ghc-mod using the stack.

here is the current setting I'm using:

 (require 'haskell-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) (add-hook 'haskell-mode-hook 'linum-mode) (add-to-list 'exec-path "~/.local/bin") (eval-after-load 'haskell-mode '(progn (define-key haskell-mode-map (kbd "Cc Cl") 'haskell-process-load-file) (define-key haskell-mode-map (kbd "Cc Cn Ct") 'haskell-process-do-type) (define-key haskell-mode-map (kbd "Cc Cn Ci") 'haskell-process-do-info) (define-key haskell-mode-map "\C-ch" 'haskell-hoogle))) (eval-after-load 'haskell-cabal '(progn (define-key haskell-cabal-mode-map (kbd "Cc Ck") 'haskell-interactive-ode-clear) (define-key haskell-cabal-mode-map (kbd "Cc Cc") 'haskell-process-cabal-build) (define-key haskell-cabal-mode-map (kbd "Cc c") 'haskell-process-cabal))) (require 'company-ghci) (push 'company-ghci company-backends) (add-hook 'haskell-mode-hook 'company-mode) (add-hook 'haskell-interactive-mode-hook 'company-mode) 

As you can see, I basically got rid of all the ghc-mod related stuff (the stack works as it is with the current haskell-mode ) and replaced the company backend (although this one is really slow and I hope to find something better)

variables

Theses you usually install in Emacs / Configuration Haskell-Mode

 (custom-set-variables ;; there is of course more in here - these are the Haskell related: '(haskell-font-lock-symbols (quote unicode)) '(haskell-hoogle-command nil) '(haskell-mode-hook (quote (linum-mode turn-on-haskell-indentation turn-on-haskell-doc-mode)) t) '(haskell-process-auto-import-loaded-modules t) '(haskell-process-load-or-reload-prompt t) '(haskell-process-log t) '(haskell-process-suggest-language-pragmas nil) '(haskell-process-suggest-no-warn-orphans t) '(haskell-process-type (quote auto)) '(haskell-process-use-presentation-mode t) '(haskell-tags-on-save t) '(inferior-haskell-wait-and-jump t) '(safe-local-variable-values (quote ((haskell-process-use-ghci . t) (haskell-indent-spaces . 4)))) (uniquify))) 

These are the packages I added:

  • Haskell mode
  • company (not Haskell related, not addiction)
  • inter-company
  • GHCi company
  • GHCi termination
  • shakespeare mode (for Yesod)
  • company-quickhelp (for a good display :i )

First

if it asks for your cabal directory - it wants to know where your myProject.cabal file is myProject.cabal - if you don't have one, just take the folder your file is in (by default - I think by default / find never let me down still).

if you need a sample .emacs-setup

Here is the part of my .emacs file that works for me:

 (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) (eval-after-load 'haskell-mode '(progn (define-key haskell-mode-map (kbd "Cc Cl") 'haskell-process-load-or-reload) (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring) (define-key haskell-mode-map (kbd "Cc Cn Ct") 'haskell-process-do-type) (define-key haskell-mode-map (kbd "Cc Cn Ci") 'haskell-process-do-info) (define-key haskell-mode-map (kbd "Cc Cn Cc") 'haskell-process-cabal-build) (define-key haskell-mode-map (kbd "Cc Cn 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 "Cc Ck") 'haskell-interactive-ode-clear) (define-key haskell-cabal-mode-map (kbd "Cc Cc") 'haskell-process-cabal-build) (define-key haskell-cabal-mode-map (kbd "Cc 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))) 

Pay attention to the part with (quote cabal-repl) - this should work with cabal sandboxes. It will also add additional logging information to a buffer named haskell-process-log, where you can find more about your problem.

I use this with ghc-mod version 5.1.0.2 compiled by GHC 7.8.3 and GHC 7.8.3.

Of course, you have to make sure your .cabal folder and the place where ghc-mod is in your path (I think you can configure this somewhere in emacs settings too, but it is much easier).

remarks

  • you need to install the ghc package in emacs not ghc-mod .
  • I used to have problems with a different version of ghc-mod and the emacs package - so make sure you get the latest version of cabal-install and then reinstall the emacs package (there were only problems parsing ghc output to my part, though)

Additional Information

If this does not help, please feel free to

run sample on my car

I edited an example file:

Helo emacs

Then I remove Cc Cl and press y:

Step 2

And accept the folder (where the file is located) and any other questions with Ret - now you should see the *haskell* buffer with the / lambda friendly message:

Step 3

Finally, I can verify that the file is uploaded:

enter image description here

+11
source share

All Articles