Greater customization of GHCi prompt
GHCi is bit more than a Haskell interpreter. With the :!
and :cd
commands, we have trivial access to the shell, making it often unnecessary to leave GHCi. For this reason GHCi has become my *de facto* primary shell.
The GHCi prompt therefore needs to show a bit more than just Haskell information. Most importantly, the current working directory is often important to me.
We can indeed customize the GHCi prompt using :set prompt
. This takes the form of a string with a single escape sequence: %s
, which is replaced with a list of currently loaded modules.
Most shells allow arbitrary user customization of the prompt. The bash
prompt has numerous escape sequences for useful information, and if those aren't enough, it allows arbitrary command calls.
GHCi should gain similar customization abilities. Ways to implement this may include:
- addition of more escape sequences, like
%pwd
. - addition of a single extra escape sequence with one parameter (an external command call), like like
%call(pwd --logical)
. - redesigning the
:set prompt
option to take not aString
but a Haskell function, like[Module] -> IO String
.
Option 2 would probably have the best power-to-simplicity ratio.
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | GHCi |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |