Skip to content

RFC: Allow prefixing result evaluated at GHCi prompt

Similar to prompt, prompt-cont (previously prompt2): allowing users to supply a prefix to evaluation results with result has two use cases I can think of

:set prompt      "    ghci> "
:set prompt-cont "    ghci| "
:set result      "    "

the desired outcome would be as indented code for IRC, also reddit code format:

    ghci> 1 + 2 + 3
    6
    ghci> reverse "hello"
    "olleh"

The other case came from this tweet

:set prompt      ""
:set result      "-- "
1 + 2 + 3
-- 6
reverse "hello"
-- "olleh"

This can be copied/pasted back to a separate GHCi session where the result is ignored.


I haven't seen this feature in any other repl, I'm not sure if this would see much use.

This wouldn't work with IO actions without some magic.

Trac metadata
Trac field Value
Version 8.0.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority lowest
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information