-
Notifications
You must be signed in to change notification settings - Fork 347
Haskell Interactive Mode Architecture
This page is about the architecture of Haskell Interactive Mode, which should be helpful for curious users and prospective hackers.
Your Emacs will contain multiple sessions: one for each Haskell project you're working on. Each session is associated with a connected GHCi process and a REPL buffer.
Emacs
/ \
/ \
Session Session
/ \ / \
Process REPL Process REPL
When you open a Haskell file in a fresh project directory, it will prompt to start a new session for the enclosing directory containing a .cabal file. It will also start a GHCi process and open up an associated REPL buffer.
There is a command queue which all communication with the GHCi process must go through:
Module 1 -> |*|
| |
Module 2 -> |*|
\_/---------> Process
|
Module 3 <--------*--------'
Only one command can run at once, anything else is queued up.
This mode consists of a few modules:
- Sessions: haskell-session.el
- Processes: haskell-process.el
- REPL: haskell-interactive-mode.el
The prompt is set to EOT (end-of-transmission), which makes it easier
to match when a command is completed and avoid interspersing with a
prompt like Prelude>
. The following interaction
λ> 1
1
λ>
In the background (and you can view this in the buffer
*haskell-process-log*
) the communication is actually:
-> "1
"
<- "1
"
<- ""
^D
is the notation Emacs uses to refer to codepoint \4
. M-x describe-char
shows:
Character code properties: customize what to show
name: <control>
old-name: END OF TRANSMISSION
general-category: Cc (Other, Control)
decomposition: (4) ('')
So, when you're looking in the log, that's what that character is.