-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Print text to terminal with colors and effects -- @package rainbow @version 0.22.0.2 -- | The innards of Rainbow. Ordinarily you should not need this module; -- instead, just import Rainbow, which re-exports the most useful -- names from this module. module Rainbow.Types type Background8 = Last Color8 type Background256 = Last Color256 type Foreground8 = Last Color8 type Foreground256 = Last Color256 -- | A simple enumeration for eight values. data Enum8 E0 :: Enum8 E1 :: Enum8 E2 :: Enum8 E3 :: Enum8 E4 :: Enum8 E5 :: Enum8 E6 :: Enum8 E7 :: Enum8 enum8toWord8 :: Enum8 -> Word8 -- | Color for an 8-color terminal. Does not affect 256-color terminals. newtype Color8 Color8 :: Maybe Enum8 -> Color8 -- | Nothing indicates to use the default color for the terminal; -- otherwise, use the corresponding Terminfo Color. unColor8 :: Color8 -> Maybe Enum8 -- | Color for an 256-color terminal. Does not affect 8-color terminals. newtype Color256 Color256 :: Maybe Word8 -> Color256 -- | Nothing indicates to use the default color for the terminal; -- otherwise, use the corresponding Terminfo Color. unColor256 :: Color256 -> Maybe Word8 -- | Any color for an 8-color terminal can also be used in a 256-color -- terminal. to256 :: Color8 -> Color256 -- | Style elements that apply in both 8 and 256 color terminals. However, -- the elements are described separately for 8 and 256 color terminals, -- so that the text appearance can change depending on how many colors a -- terminal has. data StyleCommon StyleCommon :: Last Bool -> Last Bool -> Last Bool -> Last Bool -> Last Bool -> Last Bool -> Last Bool -> Last Bool -> StyleCommon scBold :: StyleCommon -> Last Bool scFaint :: StyleCommon -> Last Bool scItalic :: StyleCommon -> Last Bool scUnderline :: StyleCommon -> Last Bool scBlink :: StyleCommon -> Last Bool scInverse :: StyleCommon -> Last Bool scInvisible :: StyleCommon -> Last Bool scStrikeout :: StyleCommon -> Last Bool -- | Describes text appearance (foreground and background colors, as well -- as other attributes such as bold) for an 8 color terminal. data Style8 Style8 :: Foreground8 -> Background8 -> StyleCommon -> Style8 foreground8 :: Style8 -> Foreground8 background8 :: Style8 -> Background8 common8 :: Style8 -> StyleCommon -- | Describes text appearance (foreground and background colors, as well -- as other attributes such as bold) for a 256 color terminal. data Style256 Style256 :: Foreground256 -> Background256 -> StyleCommon -> Style256 foreground256 :: Style256 -> Foreground256 background256 :: Style256 -> Background256 common256 :: Style256 -> StyleCommon -- | The TextSpec bundles together the styles for the 8 and 256 color -- terminals, so that the text can be portrayed on any terminal. data TextSpec TextSpec :: Style8 -> Style256 -> TextSpec style8 :: TextSpec -> Style8 style256 :: TextSpec -> Style256 -- | A chunk is some textual data coupled with a description of what color -- the text is, attributes like whether it is bold or underlined, etc. -- The chunk knows what foreground and background colors and what -- attributes to use for both an 8 color terminal and a 256 color -- terminal. data Chunk Chunk :: TextSpec -> [Text] -> Chunk -- | Specifies all the effects (such as bold, underlining, colors, etc) -- that apply to this chunk, with different effects for 8 and 256 color -- terminals; and chunkTextSpec :: Chunk -> TextSpec chunkTexts :: Chunk -> [Text] -- | Creates a Chunk from a strict Text with default colors -- and no special effects. chunkFromText :: Text -> Chunk -- | Creates a Chunk from a list of strict Text with default -- colors and no special effects. chunkFromTexts :: [Text] -> Chunk -- | Creates a Chunk from a lazy Text with default colors and -- no special effects. chunkFromLazyText :: Text -> Chunk -- | Creates a Chunk from a list of lazy Text with default -- colors and no special effects. chunkFromLazyTexts :: [Text] -> Chunk bold8 :: Chunk bold8off :: Chunk faint8 :: Chunk faint8off :: Chunk italic8 :: Chunk italic8off :: Chunk underline8 :: Chunk underline8off :: Chunk blink8 :: Chunk blink8off :: Chunk inverse8 :: Chunk inverse8off :: Chunk invisible8 :: Chunk invisible8off :: Chunk strikeout8 :: Chunk strikeout8off :: Chunk bold256 :: Chunk bold256off :: Chunk faint256 :: Chunk faint256off :: Chunk italic256 :: Chunk italic256off :: Chunk underline256 :: Chunk underline256off :: Chunk blink256 :: Chunk blink256off :: Chunk inverse256 :: Chunk inverse256off :: Chunk invisible256 :: Chunk invisible256off :: Chunk strikeout256 :: Chunk strikeout256off :: Chunk -- | Bold. What actually happens when you use Bold is going to depend on -- your terminal. For example, xterm allows you actually use a bold font -- for bold, if you have one. Otherwise, it might simulate bold by using -- overstriking. Another possibility is that your terminal might use a -- different color to indicate bold. For more details (at least for -- xterm), look at xterm (1) and search for boldColors. -- -- If your terminal uses a different color for bold, this allows an -- 8-color terminal to really have 16 colors. bold :: Chunk boldOff :: Chunk faint :: Chunk faintOff :: Chunk italic :: Chunk italicOff :: Chunk underline :: Chunk underlineOff :: Chunk blink :: Chunk blinkOff :: Chunk inverse :: Chunk inverseOff :: Chunk invisible :: Chunk invisibleOff :: Chunk strikeout :: Chunk strikeoutOff :: Chunk instance Typeable Enum8 instance Typeable Color8 instance Typeable Color256 instance Typeable StyleCommon instance Typeable Style8 instance Typeable Style256 instance Typeable TextSpec instance Typeable Chunk instance Eq Enum8 instance Ord Enum8 instance Show Enum8 instance Bounded Enum8 instance Enum Enum8 instance Generic Enum8 instance Eq Color8 instance Ord Color8 instance Show Color8 instance Generic Color8 instance Eq Color256 instance Ord Color256 instance Show Color256 instance Generic Color256 instance Show StyleCommon instance Eq StyleCommon instance Ord StyleCommon instance Generic StyleCommon instance Show Style8 instance Eq Style8 instance Ord Style8 instance Generic Style8 instance Show Style256 instance Eq Style256 instance Ord Style256 instance Generic Style256 instance Show TextSpec instance Eq TextSpec instance Ord TextSpec instance Generic TextSpec instance Eq Chunk instance Show Chunk instance Ord Chunk instance Generic Chunk instance Datatype D1Enum8 instance Constructor C1_0Enum8 instance Constructor C1_1Enum8 instance Constructor C1_2Enum8 instance Constructor C1_3Enum8 instance Constructor C1_4Enum8 instance Constructor C1_5Enum8 instance Constructor C1_6Enum8 instance Constructor C1_7Enum8 instance Datatype D1Color8 instance Constructor C1_0Color8 instance Selector S1_0_0Color8 instance Datatype D1Color256 instance Constructor C1_0Color256 instance Selector S1_0_0Color256 instance Datatype D1StyleCommon instance Constructor C1_0StyleCommon instance Selector S1_0_0StyleCommon instance Selector S1_0_1StyleCommon instance Selector S1_0_2StyleCommon instance Selector S1_0_3StyleCommon instance Selector S1_0_4StyleCommon instance Selector S1_0_5StyleCommon instance Selector S1_0_6StyleCommon instance Selector S1_0_7StyleCommon instance Datatype D1Style8 instance Constructor C1_0Style8 instance Selector S1_0_0Style8 instance Selector S1_0_1Style8 instance Selector S1_0_2Style8 instance Datatype D1Style256 instance Constructor C1_0Style256 instance Selector S1_0_0Style256 instance Selector S1_0_1Style256 instance Selector S1_0_2Style256 instance Datatype D1TextSpec instance Constructor C1_0TextSpec instance Selector S1_0_0TextSpec instance Selector S1_0_1TextSpec instance Datatype D1Chunk instance Constructor C1_0Chunk instance Selector S1_0_0Chunk instance Selector S1_0_1Chunk instance Monoid Chunk instance IsString Chunk instance Monoid TextSpec instance Monoid Style256 instance Monoid Style8 instance Monoid StyleCommon -- | Ordinarily you should not need this module; typically you will just -- import Rainbow, which re-exports the most useful things from -- this module. This module also contains data constructors that -- Rainbow does not re-export. module Rainbow.Colors -- | Resets the color (foreground or background, as appropriate) to the -- default for your terminal. Usually you will not need this, as each -- Chunk starts out with the terminal's default colors. noColor8 :: Color8 black8 :: Color8 red8 :: Color8 green8 :: Color8 yellow8 :: Color8 blue8 :: Color8 magenta8 :: Color8 cyan8 :: Color8 white8 :: Color8 -- | Resets the color (foreground or background, as appropriate) to the -- default for your terminal. Usually you will not need this, as each -- Chunk starts out with the terminal's default colors. noColor256 :: Color256 grey :: Color256 brightRed :: Color256 brightGreen :: Color256 brightYellow :: Color256 brightBlue :: Color256 brightMagenta :: Color256 brightCyan :: Color256 brightWhite :: Color256 -- | A Radiant affects both 8- and 256-color terminals. (It does -- not necessarily affect both the foreground and background; -- whether it affects the foreground, background, or both depends upon -- the context in which it is used.) data Radiant Radiant :: Color8 -> Maybe Color256 -> Radiant rad8 :: Radiant -> Color8 -- | If Nothing, use the rad8 color on 256-color terminals. rad256 :: Radiant -> Maybe Color256 -- | A Radiant with the same color for both 8- and 256-color terminals. both :: Color8 -> Radiant -- | A Radiant that uses the terminal's default colors for both 8- and -- 256-color terminals. noColorRadiant :: Radiant black :: Radiant red :: Radiant green :: Radiant yellow :: Radiant blue :: Radiant magenta :: Radiant cyan :: Radiant white :: Radiant -- | Changing colors. Instances of this class affect the background or the -- foreground color. For example, to get a Chunk that changes the -- background to red, use back red; for the -- foreground, use fore red. Whether 8-color or -- 256-color terminals (or both) are affected depends on the particular -- instance. -- -- Because Word8 is an instance of Color, you can use -- literals to affect the color of 256-color terminals. For example, if -- you have a 256 color terminal: -- --
--   putChunkLn $ "muddy yellow background" <> back (100 :: Word8)
--   
-- -- This example would not affect an 8-color terminal, as the Word8 -- instance affects 256-color terminals only. class Color a back :: Color a => a -> Chunk fore :: Color a => a -> Chunk -- | Affects the foreground and background of both 8- and 256-color -- terminals. -- | Affects the foreground and background of 8-color terminals. -- | Affects the foreground and background of 256-color terminals. instance Typeable Radiant instance Eq Radiant instance Ord Radiant instance Show Radiant instance Generic Radiant instance Datatype D1Radiant instance Constructor C1_0Radiant instance Selector S1_0_0Radiant instance Selector S1_0_1Radiant instance Color Word8 instance Color Enum8 instance Color Radiant instance Color Color256 instance Color Color8 module Rainbow.Translate single :: Char -> [ByteString] -> [ByteString] escape :: [ByteString] -> [ByteString] csi :: [ByteString] -> [ByteString] sgr :: ([ByteString] -> [ByteString]) -> [ByteString] -> [ByteString] params :: Show a => [a] -> [ByteString] -> [ByteString] sgrSingle :: Word -> [ByteString] -> [ByteString] sgrDouble :: Word -> Word -> [ByteString] -> [ByteString] normalDefault :: [ByteString] -> [ByteString] bold :: [ByteString] -> [ByteString] faint :: [ByteString] -> [ByteString] italic :: [ByteString] -> [ByteString] underline :: [ByteString] -> [ByteString] blink :: [ByteString] -> [ByteString] inverse :: [ByteString] -> [ByteString] invisible :: [ByteString] -> [ByteString] strikeout :: [ByteString] -> [ByteString] foreBlack :: [ByteString] -> [ByteString] foreRed :: [ByteString] -> [ByteString] foreGreen :: [ByteString] -> [ByteString] foreYellow :: [ByteString] -> [ByteString] foreBlue :: [ByteString] -> [ByteString] foreMagenta :: [ByteString] -> [ByteString] foreCyan :: [ByteString] -> [ByteString] foreWhite :: [ByteString] -> [ByteString] foreDefault :: [ByteString] -> [ByteString] backBlack :: [ByteString] -> [ByteString] backRed :: [ByteString] -> [ByteString] backGreen :: [ByteString] -> [ByteString] backYellow :: [ByteString] -> [ByteString] backBlue :: [ByteString] -> [ByteString] backMagenta :: [ByteString] -> [ByteString] backCyan :: [ByteString] -> [ByteString] backWhite :: [ByteString] -> [ByteString] backDefault :: [ByteString] -> [ByteString] fore256 :: Word8 -> [ByteString] -> [ByteString] back256 :: Word8 -> [ByteString] -> [ByteString] foreColor8 :: Color8 -> [ByteString] -> [ByteString] backColor8 :: Color8 -> [ByteString] -> [ByteString] foreColor256 :: Color256 -> [ByteString] -> [ByteString] backColor256 :: Color256 -> [ByteString] -> [ByteString] styleCommon :: StyleCommon -> [ByteString] -> [ByteString] style8 :: Style8 -> [ByteString] -> [ByteString] style256 :: Style256 -> [ByteString] -> [ByteString] textSpec8 :: TextSpec -> [ByteString] -> [ByteString] textSpec256 :: TextSpec -> [ByteString] -> [ByteString] -- | Convert a Chunk to a list of ByteString; do not show any -- colors. When applied to a Chunk, this function returns a -- difference list. toByteStringsColors0 :: Chunk -> [ByteString] -> [ByteString] -- | Convert a Chunk to a list of ByteString; show eight -- colors. When applied to a Chunk, this function returns a -- difference list. toByteStringsColors8 :: Chunk -> [ByteString] -> [ByteString] -- | Convert a Chunk to a list of ByteString; show 256 -- colors. When applied to a Chunk, this function returns a -- difference list. toByteStringsColors256 :: Chunk -> [ByteString] -> [ByteString] -- | Spawns a subprocess to read the output of tput colors. If -- this says there are at least 256 colors are available, returns -- toByteStringsColors256. Otherwise, if there are at least 8 -- colors available, returns toByteStringsColors8. Otherwise, -- returns toByteStringsColors0. -- -- If any IO exceptions arise during this process, they are discarded and -- toByteStringsColors0 is returned. byteStringMakerFromEnvironment :: IO (Chunk -> [ByteString] -> [ByteString]) -- | Like byteStringMakerFromEnvironment but also consults a -- provided Handle. If the Handle is not a terminal, -- toByteStringsColors0 is returned. Otherwise, the value of -- byteStringMakerFromEnvironment is returned. byteStringMakerFromHandle :: Handle -> IO (Chunk -> [ByteString] -> [ByteString]) -- | Convert a list of Chunk to a list of ByteString. The -- length of the returned list may be longer than the length of the input -- list. -- -- So, for example, to print a bunch of chunks to standard output using -- 256 colors: -- --
--   {-# LANGUAGE OverloadedStrings #-}
--   module PrintMyChunks where
--   
--   import qualified Data.ByteString as BS
--   import Rainbow
--   
--   myChunks :: [Chunk]
--   myChunks = [ "Roses" <> fore red, "\n", "Violets" <> fore blue, "\n" ]
--   
--   myPrintedChunks :: IO ()
--   myPrintedChunks = mapM_ BS.putStr
--                   . chunksToByteStrings toByteStringsColors256
--                   $ myChunks
--   
-- -- To use the highest number of colors that this terminal supports: -- --
--   myPrintedChunks' :: IO ()
--   myPrintedChunks' = do
--     printer <- byteStringMakerFromEnvironment
--     mapM_ BS.putStr
--       . chunksToByteStrings printer
--       $ myChunks
--   
chunksToByteStrings :: (Chunk -> [ByteString] -> [ByteString]) -> [Chunk] -> [ByteString] -- | Writes a Chunk to standard output. Spawns a child process to -- read the output of tput colors to determine how many colors -- to use, for every single chunk. Therefore, this is not going to win -- any speed awards. You are better off using chunksToByteStrings -- and the functions in Data.ByteString to print your -- Chunks if you are printing a lot of them. putChunk :: Chunk -> IO () -- | Writes a Chunk to standard output, and appends a newline. -- Spawns a child process to read the output of tput colors to -- determine how many colors to use, for every single chunk. Therefore, -- this is not going to win any speed awards. You are better off using -- chunksToByteStrings and the functions in Data.ByteString -- to print your Chunks if you are printing a lot of them. putChunkLn :: Chunk -> IO () -- | Rainbow handles colors and special effects for text. -- -- The building block of Rainbow is the Chunk. Each Chunk -- comes with a TextSpec, which specifies how the text should look -- on 8-color and on 256-color terminals. The Chunk is a full -- specification; that is, although Chunks are typically printed -- one after the other, the appearance of one Chunk does not -- affect the appearance of the next Chunk. -- -- You have full freedom to specify different attributes and colors for 8 -- and 256 color terminals; for instance, you can have text appear red on -- an 8-color terminal but blue on a 256-color terminal. -- -- A Chunk is a Monoid, so you can combine them using the -- usual monoid functions, including <>. You can create a -- Chunk with text using fromString, but this library is -- much more usable if you enable the OverloadedStrings GHC extension: -- --
--   {-# LANGUAGE OverloadedStrings #-}
--   
-- -- or, in GHCi: -- --
--   >>> :set -XOverloadedStrings
--   
-- -- and all future examples assume you have enabled OverloadedStrings. -- -- Here are some basic examples: -- --
--   putChunkLn $ "Some blue text" <> fore blue
--   putChunkLn $ "Blue on red background"
--                 <> fore blue <> back red
--   putChunkLn $ "Blue on red, foreground bold"
--                  <> fore blue <> back red <> bold
--   
-- -- But what makes Rainbow a little more interesting is that you can also -- specify output for 256-color terminals. To use these examples, be sure -- your TERM environment variable is set to something that supports 256 -- colors (like xterm-256color) before you start GHCi. -- --
--   putChunkLn $ "Blue on 8-color terminal, red on 256-color terminal"
--                   <> fore blue8 <> fore (to256 red8)
--   
-- -- To get a Color256, which affects only 256-color terminals, -- there are some definitions in the module such as brightRed. You -- may also use Word8 literals, like this. You need to specify the -- type as it can't be inferred: -- --
--   putChunkLn $ "Pink on 256-color terminal only"
--                  <> fore (201 :: Word8)
--   
-- -- If you mappend multiple chunks that change the same property, -- the rightmost one "wins": -- --
--   putChunkLn $ "This will be blue" <> fore red <> fore blue
--   
-- -- This property comes in handy if you want to specify a default color -- for 8- and 256-color terminals, then a more specific shade for a -- 256-color terminal: -- --
--   putChunkLn $ "Red on 8-color, pink on 256-color"
--                  <> fore red <> fore (201 :: Word8)
--   
-- -- However, if you use mappend to add additional Chunks -- that have text, the text will be appended: -- --
--   putChunkLn $ fore green <> "You will see this text "
--                <> "and this text too, but it will all be blue"
--                <> fore blue
--   
-- -- Although one chunk can have different colors on 8- and 256-color -- terminals, it cannot have different colors on the same terminal. That -- is, if you want to print some text in one color and some text in -- another color, make two chunks. module Rainbow -- | A chunk is some textual data coupled with a description of what color -- the text is, attributes like whether it is bold or underlined, etc. -- The chunk knows what foreground and background colors and what -- attributes to use for both an 8 color terminal and a 256 color -- terminal. data Chunk -- | Creates a Chunk from a strict Text with default colors -- and no special effects. chunkFromText :: Text -> Chunk -- | Creates a Chunk from a list of strict Text with default -- colors and no special effects. chunkFromTexts :: [Text] -> Chunk -- | Creates a Chunk from a lazy Text with default colors and -- no special effects. chunkFromLazyText :: Text -> Chunk -- | Creates a Chunk from a list of lazy Text with default -- colors and no special effects. chunkFromLazyTexts :: [Text] -> Chunk -- | Bold. What actually happens when you use Bold is going to depend on -- your terminal. For example, xterm allows you actually use a bold font -- for bold, if you have one. Otherwise, it might simulate bold by using -- overstriking. Another possibility is that your terminal might use a -- different color to indicate bold. For more details (at least for -- xterm), look at xterm (1) and search for boldColors. -- -- If your terminal uses a different color for bold, this allows an -- 8-color terminal to really have 16 colors. bold :: Chunk faint :: Chunk italic :: Chunk underline :: Chunk blink :: Chunk inverse :: Chunk invisible :: Chunk strikeout :: Chunk bold8 :: Chunk faint8 :: Chunk italic8 :: Chunk underline8 :: Chunk blink8 :: Chunk inverse8 :: Chunk invisible8 :: Chunk strikeout8 :: Chunk bold256 :: Chunk faint256 :: Chunk italic256 :: Chunk underline256 :: Chunk blink256 :: Chunk inverse256 :: Chunk invisible256 :: Chunk strikeout256 :: Chunk -- | Changing colors. Instances of this class affect the background or the -- foreground color. For example, to get a Chunk that changes the -- background to red, use back red; for the -- foreground, use fore red. Whether 8-color or -- 256-color terminals (or both) are affected depends on the particular -- instance. -- -- Because Word8 is an instance of Color, you can use -- literals to affect the color of 256-color terminals. For example, if -- you have a 256 color terminal: -- --
--   putChunkLn $ "muddy yellow background" <> back (100 :: Word8)
--   
-- -- This example would not affect an 8-color terminal, as the Word8 -- instance affects 256-color terminals only. class Color a back :: Color a => a -> Chunk fore :: Color a => a -> Chunk -- | A Radiant affects both 8- and 256-color terminals. (It does -- not necessarily affect both the foreground and background; -- whether it affects the foreground, background, or both depends upon -- the context in which it is used.) data Radiant Radiant :: Color8 -> Maybe Color256 -> Radiant rad8 :: Radiant -> Color8 -- | If Nothing, use the rad8 color on 256-color terminals. rad256 :: Radiant -> Maybe Color256 -- | A Radiant that uses the terminal's default colors for both 8- and -- 256-color terminals. noColorRadiant :: Radiant -- | A Radiant with the same color for both 8- and 256-color terminals. both :: Color8 -> Radiant black :: Radiant red :: Radiant green :: Radiant yellow :: Radiant blue :: Radiant magenta :: Radiant cyan :: Radiant white :: Radiant -- | A simple enumeration for eight values. data Enum8 E0 :: Enum8 E1 :: Enum8 E2 :: Enum8 E3 :: Enum8 E4 :: Enum8 E5 :: Enum8 E6 :: Enum8 E7 :: Enum8 -- | Color for an 8-color terminal. Does not affect 256-color terminals. newtype Color8 Color8 :: Maybe Enum8 -> Color8 -- | Nothing indicates to use the default color for the terminal; -- otherwise, use the corresponding Terminfo Color. unColor8 :: Color8 -> Maybe Enum8 -- | Resets the color (foreground or background, as appropriate) to the -- default for your terminal. Usually you will not need this, as each -- Chunk starts out with the terminal's default colors. noColor8 :: Color8 black8 :: Color8 red8 :: Color8 green8 :: Color8 yellow8 :: Color8 blue8 :: Color8 magenta8 :: Color8 cyan8 :: Color8 white8 :: Color8 -- | Color for an 256-color terminal. Does not affect 8-color terminals. newtype Color256 Color256 :: Maybe Word8 -> Color256 -- | Nothing indicates to use the default color for the terminal; -- otherwise, use the corresponding Terminfo Color. unColor256 :: Color256 -> Maybe Word8 -- | Resets the color (foreground or background, as appropriate) to the -- default for your terminal. Usually you will not need this, as each -- Chunk starts out with the terminal's default colors. noColor256 :: Color256 grey :: Color256 brightRed :: Color256 brightGreen :: Color256 brightYellow :: Color256 brightBlue :: Color256 brightMagenta :: Color256 brightCyan :: Color256 brightWhite :: Color256 -- | Any color for an 8-color terminal can also be used in a 256-color -- terminal. to256 :: Color8 -> Color256 -- | Spawns a subprocess to read the output of tput colors. If -- this says there are at least 256 colors are available, returns -- toByteStringsColors256. Otherwise, if there are at least 8 -- colors available, returns toByteStringsColors8. Otherwise, -- returns toByteStringsColors0. -- -- If any IO exceptions arise during this process, they are discarded and -- toByteStringsColors0 is returned. byteStringMakerFromEnvironment :: IO (Chunk -> [ByteString] -> [ByteString]) -- | Like byteStringMakerFromEnvironment but also consults a -- provided Handle. If the Handle is not a terminal, -- toByteStringsColors0 is returned. Otherwise, the value of -- byteStringMakerFromEnvironment is returned. byteStringMakerFromHandle :: Handle -> IO (Chunk -> [ByteString] -> [ByteString]) -- | Convert a Chunk to a list of ByteString; do not show any -- colors. When applied to a Chunk, this function returns a -- difference list. toByteStringsColors0 :: Chunk -> [ByteString] -> [ByteString] -- | Convert a Chunk to a list of ByteString; show eight -- colors. When applied to a Chunk, this function returns a -- difference list. toByteStringsColors8 :: Chunk -> [ByteString] -> [ByteString] -- | Convert a Chunk to a list of ByteString; show 256 -- colors. When applied to a Chunk, this function returns a -- difference list. toByteStringsColors256 :: Chunk -> [ByteString] -> [ByteString] -- | Convert a list of Chunk to a list of ByteString. The -- length of the returned list may be longer than the length of the input -- list. -- -- So, for example, to print a bunch of chunks to standard output using -- 256 colors: -- --
--   {-# LANGUAGE OverloadedStrings #-}
--   module PrintMyChunks where
--   
--   import qualified Data.ByteString as BS
--   import Rainbow
--   
--   myChunks :: [Chunk]
--   myChunks = [ "Roses" <> fore red, "\n", "Violets" <> fore blue, "\n" ]
--   
--   myPrintedChunks :: IO ()
--   myPrintedChunks = mapM_ BS.putStr
--                   . chunksToByteStrings toByteStringsColors256
--                   $ myChunks
--   
-- -- To use the highest number of colors that this terminal supports: -- --
--   myPrintedChunks' :: IO ()
--   myPrintedChunks' = do
--     printer <- byteStringMakerFromEnvironment
--     mapM_ BS.putStr
--       . chunksToByteStrings printer
--       $ myChunks
--   
chunksToByteStrings :: (Chunk -> [ByteString] -> [ByteString]) -> [Chunk] -> [ByteString] -- | Writes a Chunk to standard output. Spawns a child process to -- read the output of tput colors to determine how many colors -- to use, for every single chunk. Therefore, this is not going to win -- any speed awards. You are better off using chunksToByteStrings -- and the functions in Data.ByteString to print your -- Chunks if you are printing a lot of them. putChunk :: Chunk -> IO () -- | Writes a Chunk to standard output, and appends a newline. -- Spawns a child process to read the output of tput colors to -- determine how many colors to use, for every single chunk. Therefore, -- this is not going to win any speed awards. You are better off using -- chunksToByteStrings and the functions in Data.ByteString -- to print your Chunks if you are printing a lot of them. putChunkLn :: Chunk -> IO ()