ptGHCi is an interactive command shell for Haskell designed for high-productivity interactive coding. It is implemented as a wrapper around GHCi based on Python's
prompt-toolkit library and heavily inspired by IPython.
Highlighting is based on the
pygments library, with a variety of styles available through the
%style magic command.
Multiline commands with automatic indentation
<Meta-Enter>) to start a new line. ptGHCi will also intelligently start a new line when Enter is pressed after an operator, following keywords like
while, or when within unclosed brackets.
Real-time type display
typeBarEnabled on, ptGHCi shows the type of the identifier under the cursor in real-time while you type. Also shows the types of tab-completed suggestions.
In a menu, with the ability to cycle through options with
Edit command in external editor
ptGHCi prompt not powerful enough for you? Press
<F2> to edit the current entry at the prompt in an external editor of your choosing.
Show and re-run command history
%past magic command to list prior commands entered into the prompt during the current session, and
%rerun to rerun past commands. Useful for restoring bindings after a
ptGHCi requires ZeroMQ, PCRE, and Python 3.3+. You will also need the
pkg-config tool and Python's
pip package manager for the installation process.
stack to install the
ptghci binary on your
git clone https://github.com/litxio/ptghci cd ptghci pip3 install -r pybits/requirements.txt stack install
Usage and configuration
ptghci to start a session; any command line arguments will be passed to GHCi. The command used to start GHCi can be set via the
ghciCommand setting in the configuration file. By default it is
stack ghci if
stack is on
$PATH, otherwise just
ptGHCi uses a yaml configuration file, which it will look for in the following locations in order of decreasing priority:
ptghci.yaml.defaults lists the available options and their defaults.
Special "magic" commands understood by ptGHCi start with
% by default:
%past [-n N]: Lists the prior commands entered into the prompt during the current session. Use
%past -n Nto list up to N past commands, including commands from prior sessions.
%rerun <lines or ranges>: Re-runs past commands, provided as a line number, range, or comma-separated list of line numbers (prefixed by 'p' for history from past sessions) and ranges. Example: %rerun 3,4-5,p8,p23-p24
%hoogle <identifier>: Runs hoogle for the identifier
%style [style_name]: Without an argument, lists the available styles with sample code. With an argument, sets the style to the given style name.
If you find it annoying to have to distinguish between
: GHCi commands and '%' ptGHCi commands, you can set the
magicPrefix configuration option to ":" and use colon for everything.
- Reading from STDIN with
getLineand the like is not yet supported
- Running the GHCi debugger with
:traceis not yet supported
itvariable does not work properly with ptGHCi; in its place we set a variable
- For Windows support, see here