Personal tools

GHCi in colour

From HaskellWiki

Revision as of 01:53, 16 September 2010 by Enoksrd (Talk | contribs)

Jump to: navigation, search

This page documents efforts to colourise GHCi output.

Contents

1 Example

   Colour-ghci.png

Or a type error:

   Coloured-error.png

Output like this would be the result of running, for example:

   ghci --colour

and would appear in the console/xterm as ansi terminal coloured output.

2 Implementation

2.1 Using sed and ghci.conf

You can use sed to color the non-prompt output, and color the prompt with ghci.conf. This works better than piping into HsColour for me. See this blog post for details.

2.2 Using HsColour

An existing tool, HsColour, could be modified to operate interactively. In fact, HsColour is already interactive, and with a small patch added on 2006-12-14 to control ouput buffering better, this works relatively nicely:

   ghci 2>&1 | HsColour -tty
(thumbnail)
HsColour in action

There are small delays however, when lexing certain tokens, and the interaction with readline isn't ideal.

2.3 GuiHaskell

Neil Mitchell has a prototype gui haskell wrapper, based on gtk. Does this contain a reasonable ghci wrapper we could steal?


If you have an idea of how to do this nicely, add your proposal here.