Skip to content

Commit de933e9

Browse files
added docs for inf-haskell mode
1 parent ca94d81 commit de933e9

File tree

9 files changed

+131
-0
lines changed

9 files changed

+131
-0
lines changed

doc/haskell-mode.texi

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ interpreter (e.g. GHCi).
7474
* Spell checking strings and comments:: Using @code{flyspell-prog-mode}
7575
* Aligning code:: Aligning code using @code{align-regexp}
7676
* Rectangular commands:: Manage indentation manually
77+
* REPL:: GHCi REPL
7778
* Collapsing Haskell code:: View more code on screen
7879
* Getting Help and Reporting Bugs:: How to improve Haskell Mode
7980
* Concept index:: Index of Haskell Mode concepts
@@ -2593,6 +2594,128 @@ This will insert the contents of the last killed rectangle.
25932594
As with all Emacs modifier combos, you can type @kbd{C-x r C-h} to find
25942595
out what keys are bound beginning with the @kbd{C-x r} prefix.
25952596

2597+
@node REPL
2598+
@chapter Using GHCi REPL within Emacs
2599+
2600+
To start the REPL you can run one of the following:
2601+
2602+
@itemize
2603+
@item @kbd{M-x run-haskell}
2604+
@item @kbd{M-x switch-to-haskell}
2605+
@end itemize
2606+
2607+
This repl works with @uref{https://www.emacswiki.org/emacs/ComintMode, Comint}.
2608+
So you will feel at home if you are already using @kbd{M-x Shell} or @kbd{M-x ielm}.
2609+
2610+
@code{Inf-Haskell} is a Major mode for running GHCi, with comint.
2611+
2612+
Important key bindings in @code{Inf-haskell}:
2613+
2614+
@table @kbd
2615+
@item RET
2616+
invokes @kbd{comint-send-input}. Sends the input to the GHCi process, evaluates
2617+
the line and returns the output.
2618+
2619+
@item C-d or <delete>
2620+
deletes the forward character
2621+
2622+
@item <C-up> or M-p
2623+
invokes @kbd{comint-previous-input}. Cycle backwards through input history,
2624+
saving input.
2625+
2626+
@item <C-down> or M-n
2627+
invokes @kbd{comint-next-input}. Cycle forwards through input history.
2628+
2629+
@item C-c C-c
2630+
invokes @kbd{comint-interrupt-subjob}. Sends KeyboardInterrupt signal.
2631+
2632+
@item C-c C-\
2633+
invokes @kbd{comint-quit-subjob}. Sends KeyboardInterrupt signal.
2634+
2635+
@item C-c C-z
2636+
invokes @kbd{comint-stop-subjob}. Kills the GHCi process.
2637+
2638+
@item C-c M-r
2639+
invokes @kbd{comint-previous-matching-input-from-input}. If you are familiar
2640+
with @kbd{C-r} in bash. This is the same as that. Searches backwards through
2641+
input history for match for current input.
2642+
2643+
@item C-c M-s
2644+
invokes @kbd{comint-next-matching-input-from-input}. Searches forwards through
2645+
input history for match for current input.
2646+
2647+
@item C-c C-l
2648+
invokes @kbd{comint-dynamic-list-input-ring}. Displays a list of recent inputs
2649+
entered into the current buffer.
2650+
2651+
@item C-c M-o
2652+
invokes @kbd{comint-clear-buffer}. Clears the buffer (Only with Emacs 25.X and above)
2653+
2654+
@item C-c C-n
2655+
invokes @kbd{comint-next-prompt}. Goes to the start of the previous REPL prompt.
2656+
2657+
@item C-c C-p
2658+
invokes @kbd{comint-previous-prompt}. Goes to the start of the next REPL prompt.
2659+
2660+
@item C-c C-o
2661+
invokes @kbd{comint-delete-output}. Clears the output of the most recently evaluated
2662+
expression.
2663+
2664+
@item C-c C-e
2665+
invokes @kbd{comint-show-maximum-output}. Moves the point to the end of the buffer.
2666+
2667+
@item C-c C-u
2668+
invokes @kbd{comint-kill-input}. Kills backward, the line at point. (Use this when you have typed in an expression into the prompt
2669+
but you dont want to evaluate it.)
2670+
2671+
@item C-c C-w
2672+
invokes @kbd{backward-kill-word}. Kills backward, the word at point
2673+
2674+
@item C-c C-s
2675+
invokes @kbd{comint-write-output}. Write output from interpreter since last
2676+
input to FILENAME. Any prompt at the end of the output is not written.
2677+
@end table
2678+
2679+
@section Relevant defcustoms:
2680+
2681+
@multitable @columnfractions .40 .20 .40
2682+
@headitem Interpreter (defcustom) @tab Default Value @tab Possible Values
2683+
@item @code{haskell-process-type} @tab @code{'auto} @tab @code{'stack-ghci, 'cabal-repl, 'ghci, 'auto}
2684+
@item @code{inferior-haskell-hook} @tab @code{nil} @tab -
2685+
@item @code{haskell-process-path-ghci} @tab @code{ghci} @tab -
2686+
@item @code{haskell-process-args-ghci} @tab @code{-ferror-spans} @tab -
2687+
@item @code{haskell-process-path-cabal} @tab @code{cabal} @tab -
2688+
@item @code{haskell-process-args-cabal-repl} @tab @code{--ghc-option=-ferror-spans} @tab -
2689+
@item @code{haskell-process-path-stack} @tab @code{stack} @tab -
2690+
@item @code{haskell-process-args-stack-ghci} @tab @code{--ghci-options=-ferror-spans --no-build --no-load} @tab -
2691+
@end multitable
2692+
2693+
@section More on @code{haskell-process-type}
2694+
2695+
The Haskell interpreter used by @code{Inf-Haskell} is auto-detected by default,
2696+
but is customizable with defcustom @code{haskell-process-type}. The values
2697+
recognized by it are (default is 'auto):
2698+
2699+
@itemize
2700+
@item @code{'stack-ghci}
2701+
@item @code{'cabal-repl}
2702+
@item @code{'ghci}
2703+
@item @code{'auto}
2704+
@end itemize
2705+
2706+
if the @code{haskell-process-type} is @code{'auto}, the directories are searched for
2707+
@code{cabal.sandbox.config} or @code{stack.yaml} or @code{*.cabal} file.
2708+
If the file is present, then appropriate process is started.
2709+
2710+
When @code{cabal.sandbox.config} is found @code{haskell-process-type} is @code{'cabal-repl}.
2711+
Similarly, when @code{stack.yaml} is found @code{haskell-process-type} is @code{'stack-ghci}.
2712+
Similarly, when @code{xyz.cabal} is found @code{haskell-process-type} is @code{'cabal-repl}.
2713+
When nothing is found @code{haskell-process-type} is @code{'ghci}. When more than one
2714+
file such as @code{cabal.sandbox.config} and @code{stack.yaml} are found the following
2715+
preference is followed.
2716+
2717+
@code{cabal.sandbox.config} > @code{stack.yaml} > @code{*.cabal}
2718+
25962719
@node Collapsing Haskell code
25972720
@chapter Collapsing Haskell code
25982721

haskell-mode-test-dir11588AT1/Main.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Empty file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Empty file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Empty file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Empty file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Empty file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Empty file
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Empty file

0 commit comments

Comments
 (0)