HORIZON HASKELLDocslts/ghc-9.14.xb2f3bfd2026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · b2f3bfd · 2026-10-11

Modulegranite-0.7.4.0GHC2021

Granite.Color

Color primitives shared by the terminal and SVG backends.

Color is a 24-bit RGB value. The classic ANSI palette names (Black, BrightBlue, Default, …) are provided as bidirectional pattern synonyms that expand to fixed RGB triples, so they may be used both as expressions and in patterns exactly as before.

The two backends deliberately diverge on how a colour is realised:

  • the SVG backend renders the RGB exactly via colorHex;

  • the terminal backend approximates via ansiCode, which maps an arbitrary colour to the nearest of the 16 ANSI slots.

Because Color is now a plain RGB triple, its derived Show prints Color r g b rather than the alias name.

  • 1 type
  • 8 values
datadata Color
#

A 24-bit RGB colour.

Constructors

Instances3Eq, Read, Show
  • Eq ColorDefined in granite-0.7.4.0 · Granite.Color
  • Read ColorDefined in granite-0.7.4.0 · Granite.Color
  • Show ColorDefined in granite-0.7.4.0 · Granite.Color
valueansiCode :: Color -> Int
#

ANSI escape code for a colour. The 16 named slots (plus Default) return their canonical code; any other colour maps to the nearest ANSI slot.

valueansiOn :: Color -> Text
#

Opening ANSI escape sequence selecting a colour (its nearest ANSI slot).

valuepaint :: Color -> Char -> Text
#

Wrap a character in ANSI on/off sequences. Spaces pass through unchanged.

valuecolorHex :: Color -> Text
#

Exact #rrggbb rendering of a colour, used by the SVG backend.

valuepaletteColors :: [Color]
#

Default palette for layered charts (scatter, line, bars, …).

valuepieColors :: [Color]
#

Palette used by pie / box plots (categorical, more saturated).