haskell / haskell-mode

Emacs mode for Haskell
http://haskell.github.io/haskell-mode/
GNU General Public License v3.0
1.33k stars 343 forks source link

Unable to launch stack-ghci #1572

Open JeffreyBenjaminBrown opened 6 years ago

JeffreyBenjaminBrown commented 6 years ago

Haskell-mode is really, really nice. Thanks.

If I run "stack ghci" at the command line from within ~/code/Tidal/, I get a GHCI 8.2.1 REPL with a lot of libraries loaded. If I load a file from that folder into Emacs and run M-x run-haskell, I get a 7.10.3 REPL with only the Prelude. That's true even if I launch Emacs from within that folder.

Following the guidelines here, my .emacs file's Haskell-relevant portion looks like this:

(add-to-list 'load-path "~/.emacs.d/elpa/haskell-mode-16.1")
(custom-set-variables '(haskell-process-type 'stack-ghci))
(require 'haskell-mode)
(require 'package)
ivan-m commented 6 years ago

What is within ~/code/Tidal/? Is it a stack project?

I think it may be that run-haskell is part of inf-haskell as opposed to the haskell-process-* aspects of haskell-mode (and as such may be ignoring the haskell-process-type setting); does haskell-process-load-file work?

JeffreyBenjaminBrown commented 6 years ago

Yes, ~/code/Tidal is a clone of this fork of TidalCycles, some great live-coding software for music (it controls SuperCollider via OSC).

Following the instructions at section 13.6.1 here, I loaded the .cabal file in the root of that fork, and then ran haskell-process-load-file. It gave me a lambda prompt, but would not respond to input:

λ> 
The next big Haskell project is about to start!
If I break, you can:
  1. Restart:           M-x haskell-process-restart
  2. Configure logging: C-h v haskell-process-log (useful for debugging)
  3. General config:    M-x customize-mode
  4. Hide these tips:   C-h v haskell-process-show-debug-tips
λ> 3
λ> putStrLn 3
λ>

After each command it seemed to freeze; then I would push Enter a second time and it would show another prompt.

This might be relevant: The way Tidal loads the repl (here's the source) is by using comint:

(defvar tidal-interpreter
  "ghci"
  "*The haskell interpeter to use (default=ghci).")

(defvar tidal-interpreter-arguments
  (list "-XOverloadedStrings"
        )
  "*Arguments to the haskell interpreter (default=none).")

(defun tidal-start-haskell ()
  "Start haskell."
  (interactive)
  (if (comint-check-proc tidal-buffer)
      (error "A tidal process is already running")
    (apply
     'make-comint
     "tidal"
     tidal-interpreter
     nil
     tidal-interpreter-arguments)
    (tidal-see-output))
  ...
  (tidal-send-string ":module Sound.Tidal.Context")
  ...
ivan-m commented 6 years ago

I'm going to guess that it doesn't work with the current version of haskell-mode and may require getting an older version (which may not work with stack).