Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using this method to get a pretty GHCI colours, I am not getting any colours whatsoever. However, my terminal is a urxvt with 256 colours enabled and TERM is xterm-256color. Any idea what I could have missed?

My ~/.ghci reads:

import qualified IPPrint
import qualified Language.Haskell.HsColour as HsColour
import qualified Language.Haskell.HsColour.Colourise as HsColour
import qualified Language.Haskell.HsColour.Output as HsColour

let myColourPrefs = HsColour.defaultColourPrefs { HsColour.conid = [HsColour.Foreground HsColour.Yellow, HsColour.Bold], HsColour.conop = [HsColour.Foreground HsColour.Yellow], HsColour.string = [HsColour.Foreground HsColour.Green], HsColour.char = [HsColour.Foreground HsColour.Cyan], HsColour.number = [HsColour.Foreground HsColour.Red, HsColour.Bold], HsColour.layout = [HsColour.Foreground HsColour.White], HsColour.keyglyph = [HsColour.Foreground HsColour.White] }

let myPrint = putStrLn . HsColour.hscolour (HsColour.TTYg HsColour.XTerm256Compatible) myColourPrefs False False "" False . IPPrint.pshow

:set -interactive-print=myPrint
:set -XNoMonomorphismRestriction
:set prompt "λ "

The prompt should look like this: haskell ghci colour prompt

share|improve this question
What version of ghci do you have? What happens if you replace the function with something that prints some strong? Is it executed? – Mikel Dec 7 '12 at 21:28
@Mikel: The Glorious Glasgow Haskell Compilation System, version 7.4.1 and replacing myPrint does not seem to call it at all -- I just changed it to let myPrint = putStrLn "ook". – Sardathrion Dec 11 '12 at 8:01
up vote 2 down vote accepted

You need GHCI version >= 7.6.1 for the -interactive-print option.

Reddit: Pretty Output in GHCi (HOWTO in comments)

I was prettying up my GHCi and found a new flag in GHC 7.6 (-interactive-print)

[GHC] #5461

Milestone: 7.6.1

share|improve this answer
Has anybody this working with recent ghci versions? Not working for me with 7.10.2 – jarandaf Feb 15 at 10:40

You need to place :set -XNoMonomorphismRestriction before let myPrint = ..., tested using GHCi 7.6.3.

Alternatively, without -XNoMonomorphismRestriction:

let myPrint :: (Show a) => a -> IO (); myPrint = putStrLn . HsColour.hscolour (HsColour.TTYg HsColour.XTerm256Compatible) myColourPrefs False False "" False . IPPrint.pshow

Full .ghci(slight modification of the solution in the original Reddit post): http://pastebin.com/ry9JyDd9

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.