    {-# OPTIONS_GHC -fno-warn-orphans #-}
    {-# LANGUAGE CPP               #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE FlexibleInstances #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    module Skylighting.Format.ANSI (
             formatANSI
           ) where
    import Data.Data
    import GHC.Generics
    import Data.Int
    import Data.Word
    import Data.Binary
    import Data.Ord
    import Data.List
    import Control.Monad (mplus)
    import qualified Data.Map as Map
    import Data.Maybe (fromMaybe, isNothing, maybeToList)
    import Data.Text (Text)
    import qualified Data.Text as Text
    import Skylighting.Types
    import qualified System.Console.ANSI.Codes as ANSI
    #if !MIN_VERSION_base(4,11,0)
    import Data.Semigroup
    #endif

    formatANSI :: FormatOptions -> Style -> [SourceLine] -> Text
    formatANSI :: FormatOptions -> Style -> [SourceLine] -> Text
    formatANSI FormatOptions
    opts Style
    sty = (Text
    beforeText Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>)
                            (Text -> Text) -> ([SourceLine] -> Text) -> [SourceLine] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    afterText)
                            (Text -> Text) -> ([SourceLine] -> Text) -> [SourceLine] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> [Text] -> Text
    Text.intercalate (Char -> Text
    Text.singleton Char
    '\n')
                            ([Text] -> Text)
    -> ([SourceLine] -> [Text]) -> [SourceLine] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (LineNo -> SourceLine -> Text)
    -> [LineNo] -> [SourceLine] -> [Text]
    forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
    zipWith (FormatOptions -> Style -> LineNo -> SourceLine -> Text
    sourceLineToANSI FormatOptions
    opts Style
    sty) [LineNo
    startNum..]
        where beforeText :: Text
    beforeText = Text
    ansiResetText Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> ANSIColorLevel
    -> Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> Text
    ansiStyleText ANSIColorLevel
    clv (Style -> Maybe Color
    defaultColor Style
    sty) (Style -> Maybe Color
    backgroundColor Style
    sty) Bool
    False Bool
    False Bool
    False
              afterText :: Text
    afterText = Text
    ansiResetText
              startNum :: LineNo
    startNum = Int -> LineNo
    LineNo (Int -> LineNo) -> Int -> LineNo
    forall a b. (a -> b) -> a -> b
    $ FormatOptions -> Int
    startNumber FormatOptions
    opts
              clv :: ANSIColorLevel
    clv = FormatOptions -> ANSIColorLevel
    ansiColorLevel FormatOptions
    opts

    sourceLineToANSI :: FormatOptions -> Style -> LineNo -> SourceLine -> Text
    sourceLineToANSI :: FormatOptions -> Style -> LineNo -> SourceLine -> Text
    sourceLineToANSI FormatOptions
    opts Style
    sty LineNo
    lno = Text -> Text
    prependLineNoText
                                     (Text -> Text) -> (SourceLine -> Text) -> SourceLine -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Text] -> Text
    forall a. Monoid a => [a] -> a
    mconcat
                                     ([Text] -> Text) -> (SourceLine -> [Text]) -> SourceLine -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Token -> Text) -> SourceLine -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map (ANSIColorLevel -> Style -> Token -> Text
    tokenToANSI ANSIColorLevel
    clv Style
    sty)
        where prependLineNoText :: Text -> Text
    prependLineNoText = if FormatOptions -> Bool
    numberLines FormatOptions
    opts
                                     then (Text
    lineNoText Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <>)
                                     else Text -> Text
    forall a. a -> a
    id
              lineNoText :: Text
    lineNoText = ANSIColorLevel
    -> Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> Text
    ansiStyleText ANSIColorLevel
    clv Maybe Color
    lineNoFgc Maybe Color
    lineNoBgc Bool
    False Bool
    False Bool
    False
                             Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> String -> Text
    Text.pack (Int -> String
    forall a. Show a => a -> String
    show (Int -> String) -> Int -> String
    forall a b. (a -> b) -> a -> b
    $ LineNo -> Int
    lineNo LineNo
    lno)
                             Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> ANSIColorLevel
    -> Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> Text
    ansiStyleText ANSIColorLevel
    clv (Style -> Maybe Color
    defaultColor Style
    sty) (Style -> Maybe Color
    backgroundColor Style
    sty) Bool
    False Bool
    False Bool
    False
                             Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    "\t"
              lineNoFgc :: Maybe Color
    lineNoFgc = Style -> Maybe Color
    lineNumberColor Style
    sty Maybe Color -> Maybe Color -> Maybe Color
    forall a. Maybe a -> Maybe a -> Maybe a
    forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
    `mplus` Style -> Maybe Color
    defaultColor Style
    sty
              lineNoBgc :: Maybe Color
    lineNoBgc = Style -> Maybe Color
    lineNumberBackgroundColor Style
    sty Maybe Color -> Maybe Color -> Maybe Color
    forall a. Maybe a -> Maybe a -> Maybe a
    forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
    `mplus` Style -> Maybe Color
    backgroundColor Style
    sty
              clv :: ANSIColorLevel
    clv = FormatOptions -> ANSIColorLevel
    ansiColorLevel FormatOptions
    opts

    tokenToANSI :: ANSIColorLevel -> Style -> Token -> Text
    tokenToANSI :: ANSIColorLevel -> Style -> Token -> Text
    tokenToANSI ANSIColorLevel
    clv Style
    sty (TokenType
    tokTy, Text
    tokText) = ANSIColorLevel
    -> Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> Text
    ansiStyleText ANSIColorLevel
    clv Maybe Color
    tokFgc Maybe Color
    tokBgc Bool
    tokB Bool
    tokI Bool
    tokU
                                             Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    tokText
                                             Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> ANSIColorLevel
    -> Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> Text
    ansiStyleText ANSIColorLevel
    clv (Style -> Maybe Color
    defaultColor Style
    sty) (Style -> Maybe Color
    backgroundColor Style
    sty) Bool
    False Bool
    False Bool
    False
        where TokenStyle Maybe Color
    tokFgcRaw Maybe Color
    tokBgcRaw Bool
    tokB Bool
    tokI Bool
    tokU = TokenStyle -> Maybe TokenStyle -> TokenStyle
    forall a. a -> Maybe a -> a
    fromMaybe TokenStyle
    defStyle (Maybe TokenStyle -> TokenStyle)
    -> (Map TokenType TokenStyle -> Maybe TokenStyle)
    -> Map TokenType TokenStyle
    -> TokenStyle
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TokenType -> Map TokenType TokenStyle -> Maybe TokenStyle
    forall k a. Ord k => k -> Map k a -> Maybe a
    Map.lookup TokenType
    tokTy (Map TokenType TokenStyle -> TokenStyle)
    -> Map TokenType TokenStyle -> TokenStyle
    forall a b. (a -> b) -> a -> b
    $ Style -> Map TokenType TokenStyle
    tokenStyles Style
    sty
              tokFgc :: Maybe Color
    tokFgc = Maybe Color
    tokFgcRaw Maybe Color -> Maybe Color -> Maybe Color
    forall a. Maybe a -> Maybe a -> Maybe a
    forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
    `mplus` Style -> Maybe Color
    defaultColor Style
    sty
              tokBgc :: Maybe Color
    tokBgc = Maybe Color
    tokBgcRaw Maybe Color -> Maybe Color -> Maybe Color
    forall a. Maybe a -> Maybe a -> Maybe a
    forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
    `mplus` Style -> Maybe Color
    backgroundColor Style
    sty

    ansiStyleText :: ANSIColorLevel -- ^ color support level
                -> Maybe Color -- ^ foreground
                -> Maybe Color -- ^ background
                -> Bool -- ^ bold
                -> Bool -- ^ italic
                -> Bool -- ^ underlined
                -> Text
    ansiStyleText :: ANSIColorLevel
    -> Maybe Color -> Maybe Color -> Bool -> Bool -> Bool -> Text
    ansiStyleText ANSIColorLevel
    clv Maybe Color
    fgc Maybe Color
    bgc Bool
    b Bool
    i Bool
    u = Text
    optReset Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    sgrTextFg Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    sgrTextBg
                                        Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> (String -> Text
    Text.pack (String -> Text) -> ([SGR] -> String) -> [SGR] -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [SGR] -> String
    ANSI.setSGRCode ([SGR] -> Text) -> [SGR] -> Text
    forall a b. (a -> b) -> a -> b
    $ [[SGR]] -> [SGR]
    forall (t :: * -> *) a. Foldable t => t [a] -> [a]
    concat [[SGR]
    sgrCodeFg,
                                                                                  [SGR]
    sgrCodeBg,
                                                                                  [SGR]
    sgrCodeBold,
                                                                                  [SGR]
    sgrCodeItal,
                                                                                  [SGR]
    sgrCodeUndl])
        -- FIXME: the @ansi-terminal@ library should do the 256-color parts more cleanly someday
        where ([SGR]
    sgrCodeFg, Text
    sgrTextFg) = case ANSIColorLevel
    clv of
                ANSIColorLevel
    ANSITrueColor -> (Maybe SGR -> [SGR]
    forall a. Maybe a -> [a]
    maybeToList (Maybe SGR -> [SGR]) -> Maybe SGR -> [SGR]
    forall a b. (a -> b) -> a -> b
    $ (Color -> SGR) -> Maybe Color -> Maybe SGR
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (ConsoleLayer -> Colour Float -> SGR
    ANSI.SetRGBColor ConsoleLayer
    ANSI.Foreground (Colour Float -> SGR) -> (Color -> Colour Float) -> Color -> SGR
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Color -> Colour Float
    forall a. FromColor a => Color -> a
    fromColor) Maybe Color
    fgc, Text
    "")
                ANSIColorLevel
    ANSI256Color -> ([], Text -> Maybe Text -> Text
    forall a. a -> Maybe a -> a
    fromMaybe Text
    "" (Maybe Text -> Text) -> Maybe Text -> Text
    forall a b. (a -> b) -> a -> b
    $ (Color -> Text) -> Maybe Color -> Maybe Text
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (\Color
    c -> String -> Text
    Text.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ [Int] -> String -> String
    ANSI.csi [Int
    38, Int
    5,
                  Word8 -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Word8 -> Int)
    -> (Xterm256ColorCode -> Word8) -> Xterm256ColorCode -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Xterm256ColorCode -> Word8
    getXterm256ColorCode (Xterm256ColorCode -> Int) -> Xterm256ColorCode -> Int
    forall a b. (a -> b) -> a -> b
    $ Color -> Xterm256ColorCode
    forall a. FromColor a => Color -> a
    fromColor Color
    c] String
    "m") Maybe Color
    fgc)
                ANSIColorLevel
    ANSI16Color -> (Maybe SGR -> [SGR]
    forall a. Maybe a -> [a]
    maybeToList (Maybe SGR -> [SGR]) -> Maybe SGR -> [SGR]
    forall a b. (a -> b) -> a -> b
    $ (Color -> SGR) -> Maybe Color -> Maybe SGR
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((ColorIntensity -> Color -> SGR) -> (ColorIntensity, Color) -> SGR
    forall a b c. (a -> b -> c) -> (a, b) -> c
    uncurry (ConsoleLayer -> ColorIntensity -> Color -> SGR
    ANSI.SetColor ConsoleLayer
    ANSI.Foreground) ((ColorIntensity, Color) -> SGR)
    -> (Color -> (ColorIntensity, Color)) -> Color -> SGR
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Color -> (ColorIntensity, Color)
    forall a. FromColor a => Color -> a
    fromColor) Maybe Color
    fgc, Text
    "")
              ([SGR]
    sgrCodeBg, Text
    sgrTextBg) = case ANSIColorLevel
    clv of
                ANSIColorLevel
    ANSITrueColor -> (Maybe SGR -> [SGR]
    forall a. Maybe a -> [a]
    maybeToList (Maybe SGR -> [SGR]) -> Maybe SGR -> [SGR]
    forall a b. (a -> b) -> a -> b
    $ (Color -> SGR) -> Maybe Color -> Maybe SGR
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (ConsoleLayer -> Colour Float -> SGR
    ANSI.SetRGBColor ConsoleLayer
    ANSI.Background (Colour Float -> SGR) -> (Color -> Colour Float) -> Color -> SGR
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Color -> Colour Float
    forall a. FromColor a => Color -> a
    fromColor) Maybe Color
    bgc, Text
    "")
                ANSIColorLevel
    ANSI256Color -> ([], Text -> Maybe Text -> Text
    forall a. a -> Maybe a -> a
    fromMaybe Text
    "" (Maybe Text -> Text) -> Maybe Text -> Text
    forall a b. (a -> b) -> a -> b
    $ (Color -> Text) -> Maybe Color -> Maybe Text
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (\Color
    c -> String -> Text
    Text.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ [Int] -> String -> String
    ANSI.csi [Int
    48, Int
    5,
                  Word8 -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Word8 -> Int)
    -> (Xterm256ColorCode -> Word8) -> Xterm256ColorCode -> Int
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Xterm256ColorCode -> Word8
    getXterm256ColorCode (Xterm256ColorCode -> Int) -> Xterm256ColorCode -> Int
    forall a b. (a -> b) -> a -> b
    $ Color -> Xterm256ColorCode
    forall a. FromColor a => Color -> a
    fromColor Color
    c] String
    "m") Maybe Color
    bgc)
                ANSIColorLevel
    ANSI16Color -> (Maybe SGR -> [SGR]
    forall a. Maybe a -> [a]
    maybeToList (Maybe SGR -> [SGR]) -> Maybe SGR -> [SGR]
    forall a b. (a -> b) -> a -> b
    $ (Color -> SGR) -> Maybe Color -> Maybe SGR
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ((ColorIntensity -> Color -> SGR) -> (ColorIntensity, Color) -> SGR
    forall a b c. (a -> b -> c) -> (a, b) -> c
    uncurry (ConsoleLayer -> ColorIntensity -> Color -> SGR
    ANSI.SetColor ConsoleLayer
    ANSI.Background) ((ColorIntensity, Color) -> SGR)
    -> (Color -> (ColorIntensity, Color)) -> Color -> SGR
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Color -> (ColorIntensity, Color)
    forall a. FromColor a => Color -> a
    fromColor) Maybe Color
    bgc, Text
    "")
              optReset :: Text
    optReset = if Maybe Color -> Bool
    forall a. Maybe a -> Bool
    isNothing Maybe Color
    fgc Bool -> Bool -> Bool
    && Maybe Color -> Bool
    forall a. Maybe a -> Bool
    isNothing Maybe Color
    bgc then Text
    ansiResetText else Text
    ""
              sgrCodeBold :: [SGR]
    sgrCodeBold = [ConsoleIntensity -> SGR
    ANSI.SetConsoleIntensity (ConsoleIntensity -> SGR) -> ConsoleIntensity -> SGR
    forall a b. (a -> b) -> a -> b
    $ if Bool
    b then ConsoleIntensity
    ANSI.BoldIntensity else ConsoleIntensity
    ANSI.NormalIntensity]
              sgrCodeItal :: [SGR]
    sgrCodeItal = [Bool -> SGR
    ANSI.SetItalicized Bool
    i] -- FIXME: Not very widely supported in terminals
              sgrCodeUndl :: [SGR]
    sgrCodeUndl = [Underlining -> SGR
    ANSI.SetUnderlining (Underlining -> SGR) -> Underlining -> SGR
    forall a b. (a -> b) -> a -> b
    $ if Bool
    u then Underlining
    ANSI.SingleUnderline else Underlining
    ANSI.NoUnderline]

    ansiResetText :: Text
    ansiResetText :: Text
    ansiResetText = String -> Text
    Text.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ [SGR] -> String
    ANSI.setSGRCode [SGR
    ANSI.Reset]

    -- | Standard values taken from https://jonasjacek.github.io/colors/
    ansi16ColorList :: [((ANSI.ColorIntensity, ANSI.Color), Color)]
    ansi16ColorList :: [((ColorIntensity, Color), Color)]
    ansi16ColorList = [ ((ColorIntensity
    ANSI.Dull , Color
    ANSI.Black  ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0   Word8
    0   Word8
    0  )
                      , ((ColorIntensity
    ANSI.Dull , Color
    ANSI.Red    ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    0   Word8
    0  )
                      , ((ColorIntensity
    ANSI.Dull , Color
    ANSI.Green  ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0   Word8
    128 Word8
    0  )
                      , ((ColorIntensity
    ANSI.Dull , Color
    ANSI.Yellow ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    128 Word8
    0  )
                      , ((ColorIntensity
    ANSI.Dull , Color
    ANSI.Blue   ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0   Word8
    0   Word8
    128)
                      , ((ColorIntensity
    ANSI.Dull , Color
    ANSI.Magenta), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    0   Word8
    128)
                      , ((ColorIntensity
    ANSI.Dull , Color
    ANSI.Cyan   ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0   Word8
    128 Word8
    128)
                      , ((ColorIntensity
    ANSI.Dull , Color
    ANSI.White  ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    192 Word8
    192 Word8
    192)
                      , ((ColorIntensity
    ANSI.Vivid, Color
    ANSI.Black  ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    128 Word8
    128)
                      , ((ColorIntensity
    ANSI.Vivid, Color
    ANSI.Red    ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0   Word8
    0  )
                      , ((ColorIntensity
    ANSI.Vivid, Color
    ANSI.Green  ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0   Word8
    255 Word8
    0  )
                      , ((ColorIntensity
    ANSI.Vivid, Color
    ANSI.Yellow ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    0  )
                      , ((ColorIntensity
    ANSI.Vivid, Color
    ANSI.Blue   ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0   Word8
    0   Word8
    255)
                      , ((ColorIntensity
    ANSI.Vivid, Color
    ANSI.Magenta), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0   Word8
    255)
                      , ((ColorIntensity
    ANSI.Vivid, Color
    ANSI.Cyan   ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0   Word8
    255 Word8
    255)
                      , ((ColorIntensity
    ANSI.Vivid, Color
    ANSI.White  ), Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    255)
                      ]

    newtype Xterm256ColorCode = Xterm256ColorCode { Xterm256ColorCode -> Word8
    getXterm256ColorCode :: Word8 }
        deriving (Int -> Xterm256ColorCode -> String -> String
    [Xterm256ColorCode] -> String -> String
    Xterm256ColorCode -> String
    (Int -> Xterm256ColorCode -> String -> String)
    -> (Xterm256ColorCode -> String)
    -> ([Xterm256ColorCode] -> String -> String)
    -> Show Xterm256ColorCode
    forall a.
    (Int -> a -> String -> String)
    -> (a -> String) -> ([a] -> String -> String) -> Show a
    $cshowsPrec :: Int -> Xterm256ColorCode -> String -> String
    showsPrec :: Int -> Xterm256ColorCode -> String -> String
    $cshow :: Xterm256ColorCode -> String
    show :: Xterm256ColorCode -> String
    $cshowList :: [Xterm256ColorCode] -> String -> String
    showList :: [Xterm256ColorCode] -> String -> String
    Show, ReadPrec [Xterm256ColorCode]
    ReadPrec Xterm256ColorCode
    Int -> ReadS Xterm256ColorCode
    ReadS [Xterm256ColorCode]
    (Int -> ReadS Xterm256ColorCode)
    -> ReadS [Xterm256ColorCode]
    -> ReadPrec Xterm256ColorCode
    -> ReadPrec [Xterm256ColorCode]
    -> Read Xterm256ColorCode
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Xterm256ColorCode
    readsPrec :: Int -> ReadS Xterm256ColorCode
    $creadList :: ReadS [Xterm256ColorCode]
    readList :: ReadS [Xterm256ColorCode]
    $creadPrec :: ReadPrec Xterm256ColorCode
    readPrec :: ReadPrec Xterm256ColorCode
    $creadListPrec :: ReadPrec [Xterm256ColorCode]
    readListPrec :: ReadPrec [Xterm256ColorCode]
    Read, Xterm256ColorCode -> Xterm256ColorCode -> Bool
    (Xterm256ColorCode -> Xterm256ColorCode -> Bool)
    -> (Xterm256ColorCode -> Xterm256ColorCode -> Bool)
    -> Eq Xterm256ColorCode
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    == :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    $c/= :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    /= :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    Eq, Eq Xterm256ColorCode
    Eq Xterm256ColorCode =>
    (Xterm256ColorCode -> Xterm256ColorCode -> Ordering)
    -> (Xterm256ColorCode -> Xterm256ColorCode -> Bool)
    -> (Xterm256ColorCode -> Xterm256ColorCode -> Bool)
    -> (Xterm256ColorCode -> Xterm256ColorCode -> Bool)
    -> (Xterm256ColorCode -> Xterm256ColorCode -> Bool)
    -> (Xterm256ColorCode -> Xterm256ColorCode -> Xterm256ColorCode)
    -> (Xterm256ColorCode -> Xterm256ColorCode -> Xterm256ColorCode)
    -> Ord Xterm256ColorCode
    Xterm256ColorCode -> Xterm256ColorCode -> Bool
    Xterm256ColorCode -> Xterm256ColorCode -> Ordering
    Xterm256ColorCode -> Xterm256ColorCode -> Xterm256ColorCode
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Xterm256ColorCode -> Xterm256ColorCode -> Ordering
    compare :: Xterm256ColorCode -> Xterm256ColorCode -> Ordering
    $c< :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    < :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    $c<= :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    <= :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    $c> :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    > :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    $c>= :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    >= :: Xterm256ColorCode -> Xterm256ColorCode -> Bool
    $cmax :: Xterm256ColorCode -> Xterm256ColorCode -> Xterm256ColorCode
    max :: Xterm256ColorCode -> Xterm256ColorCode -> Xterm256ColorCode
    $cmin :: Xterm256ColorCode -> Xterm256ColorCode -> Xterm256ColorCode
    min :: Xterm256ColorCode -> Xterm256ColorCode -> Xterm256ColorCode
    Ord, Int -> Xterm256ColorCode
    Xterm256ColorCode -> Int
    Xterm256ColorCode -> [Xterm256ColorCode]
    Xterm256ColorCode -> Xterm256ColorCode
    Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode]
    Xterm256ColorCode
    -> Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode]
    (Xterm256ColorCode -> Xterm256ColorCode)
    -> (Xterm256ColorCode -> Xterm256ColorCode)
    -> (Int -> Xterm256ColorCode)
    -> (Xterm256ColorCode -> Int)
    -> (Xterm256ColorCode -> [Xterm256ColorCode])
    -> (Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode])
    -> (Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode])
    -> (Xterm256ColorCode
        -> Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode])
    -> Enum Xterm256ColorCode
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: Xterm256ColorCode -> Xterm256ColorCode
    succ :: Xterm256ColorCode -> Xterm256ColorCode
    $cpred :: Xterm256ColorCode -> Xterm256ColorCode
    pred :: Xterm256ColorCode -> Xterm256ColorCode
    $ctoEnum :: Int -> Xterm256ColorCode
    toEnum :: Int -> Xterm256ColorCode
    $cfromEnum :: Xterm256ColorCode -> Int
    fromEnum :: Xterm256ColorCode -> Int
    $cenumFrom :: Xterm256ColorCode -> [Xterm256ColorCode]
    enumFrom :: Xterm256ColorCode -> [Xterm256ColorCode]
    $cenumFromThen :: Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode]
    enumFromThen :: Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode]
    $cenumFromTo :: Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode]
    enumFromTo :: Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode]
    $cenumFromThenTo :: Xterm256ColorCode
    -> Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode]
    enumFromThenTo :: Xterm256ColorCode
    -> Xterm256ColorCode -> Xterm256ColorCode -> [Xterm256ColorCode]
    Enum, Xterm256ColorCode
    Xterm256ColorCode -> Xterm256ColorCode -> Bounded Xterm256ColorCode
    forall a. a -> a -> Bounded a
    $cminBound :: Xterm256ColorCode
    minBound :: Xterm256ColorCode
    $cmaxBound :: Xterm256ColorCode
    maxBound :: Xterm256ColorCode
    Bounded, Typeable Xterm256ColorCode
    Typeable Xterm256ColorCode =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g)
     -> Xterm256ColorCode
     -> c Xterm256ColorCode)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Xterm256ColorCode)
    -> (Xterm256ColorCode -> Constr)
    -> (Xterm256ColorCode -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Xterm256ColorCode))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c Xterm256ColorCode))
    -> ((forall b. Data b => b -> b)
        -> Xterm256ColorCode -> Xterm256ColorCode)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Xterm256ColorCode -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Xterm256ColorCode -> r)
    -> (forall u.
        (forall d. Data d => d -> u) -> Xterm256ColorCode -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> Xterm256ColorCode -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d)
        -> Xterm256ColorCode -> m Xterm256ColorCode)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> Xterm256ColorCode -> m Xterm256ColorCode)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d)
        -> Xterm256ColorCode -> m Xterm256ColorCode)
    -> Data Xterm256ColorCode
    Xterm256ColorCode -> Constr
    Xterm256ColorCode -> DataType
    (forall b. Data b => b -> b)
    -> Xterm256ColorCode -> Xterm256ColorCode
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u.
    Int -> (forall d. Data d => d -> u) -> Xterm256ColorCode -> u
    forall u. (forall d. Data d => d -> u) -> Xterm256ColorCode -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Xterm256ColorCode -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Xterm256ColorCode -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Xterm256ColorCode -> m Xterm256ColorCode
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Xterm256ColorCode -> m Xterm256ColorCode
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Xterm256ColorCode
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Xterm256ColorCode -> c Xterm256ColorCode
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Xterm256ColorCode)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Xterm256ColorCode)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Xterm256ColorCode -> c Xterm256ColorCode
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Xterm256ColorCode -> c Xterm256ColorCode
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Xterm256ColorCode
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Xterm256ColorCode
    $ctoConstr :: Xterm256ColorCode -> Constr
    toConstr :: Xterm256ColorCode -> Constr
    $cdataTypeOf :: Xterm256ColorCode -> DataType
    dataTypeOf :: Xterm256ColorCode -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Xterm256ColorCode)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Xterm256ColorCode)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Xterm256ColorCode)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c Xterm256ColorCode)
    $cgmapT :: (forall b. Data b => b -> b)
    -> Xterm256ColorCode -> Xterm256ColorCode
    gmapT :: (forall b. Data b => b -> b)
    -> Xterm256ColorCode -> Xterm256ColorCode
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Xterm256ColorCode -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Xterm256ColorCode -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Xterm256ColorCode -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Xterm256ColorCode -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Xterm256ColorCode -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Xterm256ColorCode -> [u]
    $cgmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> Xterm256ColorCode -> u
    gmapQi :: forall u.
    Int -> (forall d. Data d => d -> u) -> Xterm256ColorCode -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Xterm256ColorCode -> m Xterm256ColorCode
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> Xterm256ColorCode -> m Xterm256ColorCode
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Xterm256ColorCode -> m Xterm256ColorCode
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Xterm256ColorCode -> m Xterm256ColorCode
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Xterm256ColorCode -> m Xterm256ColorCode
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> Xterm256ColorCode -> m Xterm256ColorCode
    Data, Typeable, (forall x. Xterm256ColorCode -> Rep Xterm256ColorCode x)
    -> (forall x. Rep Xterm256ColorCode x -> Xterm256ColorCode)
    -> Generic Xterm256ColorCode
    forall x. Rep Xterm256ColorCode x -> Xterm256ColorCode
    forall x. Xterm256ColorCode -> Rep Xterm256ColorCode x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Xterm256ColorCode -> Rep Xterm256ColorCode x
    from :: forall x. Xterm256ColorCode -> Rep Xterm256ColorCode x
    $cto :: forall x. Rep Xterm256ColorCode x -> Xterm256ColorCode
    to :: forall x. Rep Xterm256ColorCode x -> Xterm256ColorCode
    Generic)

    instance Binary Xterm256ColorCode

    -- | Converted from https://jonasjacek.github.io/colors/data.json, then slightly rearranged
    ansi256ColorList :: [(Xterm256ColorCode, Color)]
    ansi256ColorList :: [(Xterm256ColorCode, Color)]
    ansi256ColorList = [ (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    232, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    8 Word8
    8 Word8
    8) -- grayscale colors
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    233, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    18 Word8
    18 Word8
    18)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    234, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    28 Word8
    28 Word8
    28)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    235, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    38 Word8
    38 Word8
    38)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    236, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    48 Word8
    48 Word8
    48)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    237, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    58 Word8
    58 Word8
    58)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    238, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    68 Word8
    68 Word8
    68)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    239, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    78 Word8
    78 Word8
    78)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    240, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    88 Word8
    88 Word8
    88)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    241, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    98 Word8
    98 Word8
    98)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    242, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    108 Word8
    108 Word8
    108)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    243, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    118 Word8
    118 Word8
    118)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    244, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    128 Word8
    128)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    245, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    138 Word8
    138 Word8
    138)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    246, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    148 Word8
    148 Word8
    148)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    247, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    158 Word8
    158 Word8
    158)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    248, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    168 Word8
    168 Word8
    168)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    249, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    178 Word8
    178 Word8
    178)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    250, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    188 Word8
    188 Word8
    188)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    251, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    198 Word8
    198 Word8
    198)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    252, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    208 Word8
    208 Word8
    208)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    253, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    218 Word8
    218 Word8
    218)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    254, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    228 Word8
    228 Word8
    228)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    255, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    238 Word8
    238 Word8
    238)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    16, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    0) -- RGB cube colors
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    17, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    18, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    19, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    20, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    21, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    22, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    95 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    23, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    95 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    24, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    95 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    25, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    95 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    26, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    95 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    27, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    95 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    28, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    135 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    29, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    135 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    30, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    135 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    31, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    135 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    32, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    135 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    33, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    135 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    34, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    175 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    35, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    175 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    36, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    175 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    37, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    175 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    38, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    175 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    39, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    175 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    40, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    215 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    41, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    215 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    42, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    215 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    43, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    215 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    44, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    215 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    45, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    215 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    46, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    255 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    47, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    255 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    48, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    255 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    49, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    255 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    50, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    255 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    51, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    255 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    52, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    0 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    53, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    0 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    54, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    0 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    55, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    0 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    56, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    0 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    57, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    0 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    58, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    95 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    59, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    95 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    60, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    95 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    61, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    95 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    62, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    95 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    63, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    95 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    64, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    135 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    65, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    135 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    66, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    135 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    67, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    135 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    68, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    135 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    69, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    135 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    70, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    175 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    71, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    175 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    72, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    175 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    73, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    175 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    74, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    175 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    75, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    175 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    76, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    215 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    77, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    215 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    78, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    215 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    79, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    215 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    80, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    215 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    81, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    215 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    82, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    255 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    83, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    255 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    84, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    255 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    85, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    255 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    86, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    255 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    87, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    95 Word8
    255 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    88, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    0 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    89, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    0 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    90, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    0 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    91, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    0 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    92, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    0 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    93, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    0 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    94, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    95 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    95, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    95 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    96, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    95 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    97, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    95 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    98, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    95 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    99, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    95 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    100, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    135 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    101, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    135 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    102, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    135 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    103, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    135 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    104, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    135 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    105, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    135 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    106, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    175 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    107, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    175 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    108, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    175 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    109, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    175 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    110, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    175 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    111, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    175 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    112, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    215 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    113, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    215 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    114, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    215 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    115, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    215 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    116, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    215 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    117, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    215 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    118, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    255 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    119, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    255 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    120, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    255 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    121, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    255 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    122, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    255 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    123, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    135 Word8
    255 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    124, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    0 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    125, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    0 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    126, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    0 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    127, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    0 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    128, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    0 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    129, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    0 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    130, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    95 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    131, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    95 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    132, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    95 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    133, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    95 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    134, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    95 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    135, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    95 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    136, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    135 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    137, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    135 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    138, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    135 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    139, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    135 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    140, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    135 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    141, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    135 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    142, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    175 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    143, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    175 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    144, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    175 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    145, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    175 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    146, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    175 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    147, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    175 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    148, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    215 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    149, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    215 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    150, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    215 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    151, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    215 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    152, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    215 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    153, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    215 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    154, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    255 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    155, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    255 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    156, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    255 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    157, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    255 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    158, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    255 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    159, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    175 Word8
    255 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    160, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    0 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    161, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    0 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    162, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    0 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    163, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    0 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    164, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    0 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    165, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    0 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    166, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    95 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    167, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    95 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    168, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    95 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    169, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    95 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    170, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    95 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    171, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    95 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    172, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    135 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    173, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    135 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    174, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    135 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    175, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    135 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    176, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    135 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    177, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    135 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    178, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    175 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    179, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    175 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    180, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    175 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    181, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    175 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    182, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    175 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    183, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    175 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    184, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    215 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    185, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    215 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    186, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    215 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    187, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    215 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    188, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    215 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    189, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    215 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    190, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    255 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    191, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    255 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    192, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    255 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    193, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    255 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    194, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    255 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    195, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    215 Word8
    255 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    196, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    197, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    198, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    199, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    200, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    201, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    202, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    95 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    203, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    95 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    204, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    95 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    205, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    95 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    206, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    95 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    207, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    95 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    208, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    135 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    209, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    135 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    210, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    135 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    211, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    135 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    212, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    135 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    213, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    135 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    214, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    175 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    215, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    175 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    216, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    175 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    217, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    175 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    218, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    175 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    219, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    175 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    220, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    215 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    221, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    215 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    222, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    215 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    223, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    215 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    224, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    215 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    225, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    215 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    226, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    227, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    95)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    228, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    135)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    229, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    175)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    230, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    215)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    231, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    0, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    0) -- “system” colors
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    1, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    0 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    2, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    128 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    3, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    128 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    4, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    128)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    5, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    0 Word8
    128)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    6, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    128 Word8
    128)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    7, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    192 Word8
    192 Word8
    192)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    8, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    128 Word8
    128 Word8
    128)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    9, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    10, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    255 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    11, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    0)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    12, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    0 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    13, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    0 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    14, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    0 Word8
    255 Word8
    255)
                       , (Word8 -> Xterm256ColorCode
    Xterm256ColorCode Word8
    15, Word8 -> Word8 -> Word8 -> Color
    RGB Word8
    255 Word8
    255 Word8
    255)
                       ]

    instance ToColor Xterm256ColorCode where
        toColor :: Xterm256ColorCode -> Maybe Color
    toColor = (Xterm256ColorCode -> [(Xterm256ColorCode, Color)] -> Maybe Color)
    -> [(Xterm256ColorCode, Color)] -> Xterm256ColorCode -> Maybe Color
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Xterm256ColorCode -> [(Xterm256ColorCode, Color)] -> Maybe Color
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup [(Xterm256ColorCode, Color)]
    ansi256ColorList -- cannot actually fail

    instance ToColor (ANSI.ColorIntensity, ANSI.Color) where
        toColor :: (ColorIntensity, Color) -> Maybe Color
    toColor = ((ColorIntensity, Color)
     -> [((ColorIntensity, Color), Color)] -> Maybe Color)
    -> [((ColorIntensity, Color), Color)]
    -> (ColorIntensity, Color)
    -> Maybe Color
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip (ColorIntensity, Color)
    -> [((ColorIntensity, Color), Color)] -> Maybe Color
    forall a b. Eq a => a -> [(a, b)] -> Maybe b
    lookup [((ColorIntensity, Color), Color)]
    ansi16ColorList -- cannot actually fail

    -- | Warning: this conversion is extremely approximate!
    instance FromColor (ANSI.ColorIntensity, ANSI.Color) where
        fromColor :: Color -> (ColorIntensity, Color)
    fromColor = [((ColorIntensity, Color), Color)]
    -> Color -> (ColorIntensity, Color)
    forall a. [(a, Color)] -> Color -> a
    findApproximateColor [((ColorIntensity, Color), Color)]
    ansi16ColorList

    -- | Warning: this conversion is noticeably approximate!
    instance FromColor Xterm256ColorCode where
        -- Same algorithm as above
        fromColor :: Color -> Xterm256ColorCode
    fromColor = [(Xterm256ColorCode, Color)] -> Color -> Xterm256ColorCode
    forall a. [(a, Color)] -> Color -> a
    findApproximateColor [(Xterm256ColorCode, Color)]
    ansi256ColorList

    colorDistance :: Color -> Color -> Int16
    colorDistance :: Color -> Color -> Int16
    colorDistance (RGB Word8
    r1 Word8
    g1 Word8
    b1) (RGB Word8
    r2 Word8
    g2 Word8
    b2) = Int16 -> Int16
    forall a. Num a => a -> a
    abs (Word8 -> Int16
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    r1 Int16 -> Int16 -> Int16
    forall a. Num a => a -> a -> a
    - Word8 -> Int16
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    r2)
                                                    Int16 -> Int16 -> Int16
    forall a. Num a => a -> a -> a
    + Int16 -> Int16
    forall a. Num a => a -> a
    abs (Word8 -> Int16
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    g1 Int16 -> Int16 -> Int16
    forall a. Num a => a -> a -> a
    - Word8 -> Int16
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    g2)
                                                    Int16 -> Int16 -> Int16
    forall a. Num a => a -> a -> a
    + Int16 -> Int16
    forall a. Num a => a -> a
    abs (Word8 -> Int16
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    b1 Int16 -> Int16 -> Int16
    forall a. Num a => a -> a -> a
    - Word8 -> Int16
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Word8
    b2)

    -- This is the most naïve possible nearest-neighbor search;
    -- it could almost certainly be optimized, if its speed matters at all.
    findApproximateColor :: [(a, Color)] -> Color -> a
    findApproximateColor :: forall a. [(a, Color)] -> Color -> a
    findApproximateColor [(a, Color)]
    acs Color
    c = let ranked :: [((a, Color), Int16)]
    ranked = ((a, Color) -> ((a, Color), Int16))
    -> [(a, Color)] -> [((a, Color), Int16)]
    forall a b. (a -> b) -> [a] -> [b]
    map (\(a, Color)
    ac -> ((a, Color)
    ac, Color -> Color -> Int16
    colorDistance Color
    c (Color -> Int16) -> Color -> Int16
    forall a b. (a -> b) -> a -> b
    $ (a, Color) -> Color
    forall a b. (a, b) -> b
    snd (a, Color)
    ac)) [(a, Color)]
    acs
                          in (a, Color) -> a
    forall a b. (a, b) -> a
    fst ((a, Color) -> a)
    -> (((a, Color), Int16) -> (a, Color)) -> ((a, Color), Int16) -> a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ((a, Color), Int16) -> (a, Color)
    forall a b. (a, b) -> a
    fst (((a, Color), Int16) -> a) -> ((a, Color), Int16) -> a
    forall a b. (a -> b) -> a -> b
    $ (((a, Color), Int16) -> ((a, Color), Int16) -> Ordering)
    -> [((a, Color), Int16)] -> ((a, Color), Int16)
    forall (t :: * -> *) a.
    Foldable t =>
    (a -> a -> Ordering) -> t a -> a
    minimumBy ((((a, Color), Int16) -> Int16)
    -> ((a, Color), Int16) -> ((a, Color), Int16) -> Ordering
    forall a b. Ord a => (b -> a) -> b -> b -> Ordering
    comparing ((a, Color), Int16) -> Int16
    forall a b. (a, b) -> b
    snd) [((a, Color), Int16)]
    ranked