GHCI: Multiline mode
Motivation
In GHCi you can run multiline commands with :{ ... :}
. However this mode is very unpleasant and really only works when you're pasting a code snippet. Once you've hit enter, you cannot modify previous lines. It also makes re-running previous multi-line commands too onerous to actually use (see #3984).
Proposal
EDIT: A better proposal: Automatically enter this "multiline mode" when the line to be run is syntactically incomplete. This would allow us to have this feature enabled at all times and even help prevent people from accidentally running lines with syntax errors. It is also a mode commonly found in other REPLs (ipython, SQL, etc.).
I propose we create a prompt mode that acts like many CLI SQL tools: it lets you keep editing a multiline string until you add a final delimiter telling the "return" key to actually run the command. This could simply be a new option in GHCi enabled via :set
. Perhaps :set multiline
/:unset multiline
. With such a tool, I imagine that :{ ... :}
would be all but obsolete.
I am unfamiliar with the implementation of GHCi so I don't know how to propose an implementation, but with sufficient guidance I would be willing to take a stab at it, if the design were clear and liked by many.