HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

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.

Synopsis
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).