Description
In many emacs language modes, there are commands for interacting with a repl/interpreter for that language. Often there are commands for sending just specific parts of the file (like single expressions or subexpressions or regions) to the repl.
For example (among, no doubt, numerous others):
- In ocaml, with tuareg C-c C-e (tuareg-eval-phrase)
- In clojure, with cider (M-x cider-jack-in) C-c C-e (cider-eval-last-sexp)
- In ruby, with ruby-mode C-x C-e (ruby-send-last-sexp)
I'm trying to do this in haskell-mode. I can type stuff in the repl within emacs and it seems to work. And while editing a buffer containing a .hs file, I can load the WHOLE file into the repl with:
C-c C-l (haskell-process-load-file).
BUT I'm not sure how to send to the repl:
- only a portion of the file
- "naked expressions"
I tried a file with just a single expression and it gave an error. This is no big deal if you have to evaluate the whole file anyway. But if a "portion" were possible (point 1) then being able to send an expression or subexpression to the repl is sometimes useful. I'm just having a little look at Haskell, and am just trying to get a nice interactive setup. Any suggestions on how to send portions of a Haskell file to the repl would be much appreciated. I'm hoping there's just some configuration technique that I'm not aware of. I guess it might be possible to write an emacs mode or modify haskell-mode to do this. But as just a basic emacs user, that's probably not a good option. And also, if it is not possible in the existing haskell-mode (written by someone who knows a lot more Haskell and emacs than I do) then maybe there's some technical difficulty with doing it. Considering it's a fairly obvious thing to do and is done for many other languages.