rainbow-0.28.0.4: Print text to terminal with colors and effects

Safe HaskellNone
LanguageHaskell2010

Rainbow.Types

Description

All the main types in Rainbow. Using this module you can specify that you want different formatting for 8- and 256-color terminals. Many of the names in this module conflict with the names in Rainbow, so it's probably best to import this module qualified.

Synopsis

Documentation

newtype Color a #

A color; a Nothing value means that the terminal's default color is used. The type of the Maybe generally will be an Enum8 to represent one of 8 colors, or a Word8 to represent one of 256 colors.

Constructors

Color (Maybe a) 

Instances

Functor Color # 

Methods

fmap :: (a -> b) -> Color a -> Color b #

(<$) :: a -> Color b -> Color a #

Foldable Color # 

Methods

fold :: Monoid m => Color m -> m #

foldMap :: Monoid m => (a -> m) -> Color a -> m #

foldr :: (a -> b -> b) -> b -> Color a -> b #

foldr' :: (a -> b -> b) -> b -> Color a -> b #

foldl :: (b -> a -> b) -> b -> Color a -> b #

foldl' :: (b -> a -> b) -> b -> Color a -> b #

foldr1 :: (a -> a -> a) -> Color a -> a #

foldl1 :: (a -> a -> a) -> Color a -> a #

toList :: Color a -> [a] #

null :: Color a -> Bool #

length :: Color a -> Int #

elem :: Eq a => a -> Color a -> Bool #

maximum :: Ord a => Color a -> a #

minimum :: Ord a => Color a -> a #

sum :: Num a => Color a -> a #

product :: Num a => Color a -> a #

Traversable Color # 

Methods

traverse :: Applicative f => (a -> f b) -> Color a -> f (Color b) #

sequenceA :: Applicative f => Color (f a) -> f (Color a) #

mapM :: Monad m => (a -> m b) -> Color a -> m (Color b) #

sequence :: Monad m => Color (m a) -> m (Color a) #

Eq a => Eq (Color a) # 

Methods

(==) :: Color a -> Color a -> Bool #

(/=) :: Color a -> Color a -> Bool #

Ord a => Ord (Color a) # 

Methods

compare :: Color a -> Color a -> Ordering #

(<) :: Color a -> Color a -> Bool #

(<=) :: Color a -> Color a -> Bool #

(>) :: Color a -> Color a -> Bool #

(>=) :: Color a -> Color a -> Bool #

max :: Color a -> Color a -> Color a #

min :: Color a -> Color a -> Color a #

Show a => Show (Color a) # 

Methods

showsPrec :: Int -> Color a -> ShowS #

show :: Color a -> String #

showList :: [Color a] -> ShowS #

Generic (Color a) # 

Associated Types

type Rep (Color a) :: * -> * #

Methods

from :: Color a -> Rep (Color a) x #

to :: Rep (Color a) x -> Color a #

Monoid (Color a) #

Takes the last non-Nothing Color. mempty is no color.

Methods

mempty :: Color a #

mappend :: Color a -> Color a -> Color a #

mconcat :: [Color a] -> Color a #

type Rep (Color a) # 
type Rep (Color a) = D1 (MetaData "Color" "Rainbow.Types" "rainbow-0.28.0.4-5DoLUaf2JtM7WNAQdkJiA9" True) (C1 (MetaCons "Color" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe a))))

data Enum8 #

A simple enumeration for eight values. Represents eight colors.

Constructors

E0 
E1 
E2 
E3 
E4 
E5 
E6 
E7 

Instances

Bounded Enum8 # 
Enum Enum8 # 
Eq Enum8 # 

Methods

(==) :: Enum8 -> Enum8 -> Bool #

(/=) :: Enum8 -> Enum8 -> Bool #

Ord Enum8 # 

Methods

compare :: Enum8 -> Enum8 -> Ordering #

(<) :: Enum8 -> Enum8 -> Bool #

(<=) :: Enum8 -> Enum8 -> Bool #

(>) :: Enum8 -> Enum8 -> Bool #

(>=) :: Enum8 -> Enum8 -> Bool #

max :: Enum8 -> Enum8 -> Enum8 #

min :: Enum8 -> Enum8 -> Enum8 #

Show Enum8 # 

Methods

showsPrec :: Int -> Enum8 -> ShowS #

show :: Enum8 -> String #

showList :: [Enum8] -> ShowS #

Generic Enum8 # 

Associated Types

type Rep Enum8 :: * -> * #

Methods

from :: Enum8 -> Rep Enum8 x #

to :: Rep Enum8 x -> Enum8 #

type Rep Enum8 # 
type Rep Enum8 = D1 (MetaData "Enum8" "Rainbow.Types" "rainbow-0.28.0.4-5DoLUaf2JtM7WNAQdkJiA9" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "E0" PrefixI False) U1) (C1 (MetaCons "E1" PrefixI False) U1)) ((:+:) (C1 (MetaCons "E2" PrefixI False) U1) (C1 (MetaCons "E3" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "E4" PrefixI False) U1) (C1 (MetaCons "E5" PrefixI False) U1)) ((:+:) (C1 (MetaCons "E6" PrefixI False) U1) (C1 (MetaCons "E7" PrefixI False) U1))))

data Format #

Text formatting such as bold, italic, etc.

Constructors

Format 

Instances

Eq Format # 

Methods

(==) :: Format -> Format -> Bool #

(/=) :: Format -> Format -> Bool #

Ord Format # 
Show Format # 
Generic Format # 

Associated Types

type Rep Format :: * -> * #

Methods

from :: Format -> Rep Format x #

to :: Rep Format x -> Format #

Monoid Format #

For each field, the resulting field is True if either field is True. For mempty, every field is False.

type Rep Format # 

strikeout :: Functor f => (Bool -> f Bool) -> Format -> f Format #

invisible :: Functor f => (Bool -> f Bool) -> Format -> f Format #

inverse :: Functor f => (Bool -> f Bool) -> Format -> f Format #

blink :: Functor f => (Bool -> f Bool) -> Format -> f Format #

underline :: Functor f => (Bool -> f Bool) -> Format -> f Format #

italic :: Functor f => (Bool -> f Bool) -> Format -> f Format #

faint :: Functor f => (Bool -> f Bool) -> Format -> f Format #

bold :: Functor f => (Bool -> f Bool) -> Format -> f Format #

data Style a #

The foreground and background color, and the Format. This represents all colors and formatting attributes for either an 8- or 256-color terminal.

Constructors

Style 

Fields

Instances

Functor Style # 

Methods

fmap :: (a -> b) -> Style a -> Style b #

(<$) :: a -> Style b -> Style a #

Foldable Style # 

Methods

fold :: Monoid m => Style m -> m #

foldMap :: Monoid m => (a -> m) -> Style a -> m #

foldr :: (a -> b -> b) -> b -> Style a -> b #

foldr' :: (a -> b -> b) -> b -> Style a -> b #

foldl :: (b -> a -> b) -> b -> Style a -> b #

foldl' :: (b -> a -> b) -> b -> Style a -> b #

foldr1 :: (a -> a -> a) -> Style a -> a #

foldl1 :: (a -> a -> a) -> Style a -> a #

toList :: Style a -> [a] #

null :: Style a -> Bool #

length :: Style a -> Int #

elem :: Eq a => a -> Style a -> Bool #

maximum :: Ord a => Style a -> a #

minimum :: Ord a => Style a -> a #

sum :: Num a => Style a -> a #

product :: Num a => Style a -> a #

Traversable Style # 

Methods

traverse :: Applicative f => (a -> f b) -> Style a -> f (Style b) #

sequenceA :: Applicative f => Style (f a) -> f (Style a) #

mapM :: Monad m => (a -> m b) -> Style a -> m (Style b) #

sequence :: Monad m => Style (m a) -> m (Style a) #

Eq a => Eq (Style a) # 

Methods

(==) :: Style a -> Style a -> Bool #

(/=) :: Style a -> Style a -> Bool #

Ord a => Ord (Style a) # 

Methods

compare :: Style a -> Style a -> Ordering #

(<) :: Style a -> Style a -> Bool #

(<=) :: Style a -> Style a -> Bool #

(>) :: Style a -> Style a -> Bool #

(>=) :: Style a -> Style a -> Bool #

max :: Style a -> Style a -> Style a #

min :: Style a -> Style a -> Style a #

Show a => Show (Style a) # 

Methods

showsPrec :: Int -> Style a -> ShowS #

show :: Style a -> String #

showList :: [Style a] -> ShowS #

Generic (Style a) # 

Associated Types

type Rep (Style a) :: * -> * #

Methods

from :: Style a -> Rep (Style a) x #

to :: Rep (Style a) x -> Style a #

Monoid (Style a) #

Uses the underlying Monoid instances for Color and Format.

Methods

mempty :: Style a #

mappend :: Style a -> Style a -> Style a #

mconcat :: [Style a] -> Style a #

type Rep (Style a) # 

format :: Functor f => (Format -> f Format) -> Style a -> f (Style a) #

back :: Functor f => (Color a -> f (Color a)) -> Style a -> f (Style a) #

fore :: Functor f => (Color a -> f (Color a)) -> Style a -> f (Style a) #

data Scheme #

Holds the Style for both 8- and 256-color terminals.

Constructors

Scheme 

Instances

Eq Scheme # 

Methods

(==) :: Scheme -> Scheme -> Bool #

(/=) :: Scheme -> Scheme -> Bool #

Ord Scheme # 
Show Scheme # 
Generic Scheme # 

Associated Types

type Rep Scheme :: * -> * #

Methods

from :: Scheme -> Rep Scheme x #

to :: Rep Scheme x -> Scheme #

Monoid Scheme # 
type Rep Scheme # 
type Rep Scheme = D1 (MetaData "Scheme" "Rainbow.Types" "rainbow-0.28.0.4-5DoLUaf2JtM7WNAQdkJiA9" False) (C1 (MetaCons "Scheme" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_style8") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Style Enum8))) (S1 (MetaSel (Just Symbol "_style256") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Style Word8)))))

style256 :: Functor f => (Style Word8 -> f (Style Word8)) -> Scheme -> f Scheme #

style8 :: Functor f => (Style Enum8 -> f (Style Enum8)) -> Scheme -> f Scheme #

data Chunk a #

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.

Constructors

Chunk 

Fields

Instances

Functor Chunk # 

Methods

fmap :: (a -> b) -> Chunk a -> Chunk b #

(<$) :: a -> Chunk b -> Chunk a #

Foldable Chunk # 

Methods

fold :: Monoid m => Chunk m -> m #

foldMap :: Monoid m => (a -> m) -> Chunk a -> m #

foldr :: (a -> b -> b) -> b -> Chunk a -> b #

foldr' :: (a -> b -> b) -> b -> Chunk a -> b #

foldl :: (b -> a -> b) -> b -> Chunk a -> b #

foldl' :: (b -> a -> b) -> b -> Chunk a -> b #

foldr1 :: (a -> a -> a) -> Chunk a -> a #

foldl1 :: (a -> a -> a) -> Chunk a -> a #

toList :: Chunk a -> [a] #

null :: Chunk a -> Bool #

length :: Chunk a -> Int #

elem :: Eq a => a -> Chunk a -> Bool #

maximum :: Ord a => Chunk a -> a #

minimum :: Ord a => Chunk a -> a #

sum :: Num a => Chunk a -> a #

product :: Num a => Chunk a -> a #

Traversable Chunk # 

Methods

traverse :: Applicative f => (a -> f b) -> Chunk a -> f (Chunk b) #

sequenceA :: Applicative f => Chunk (f a) -> f (Chunk a) #

mapM :: Monad m => (a -> m b) -> Chunk a -> m (Chunk b) #

sequence :: Monad m => Chunk (m a) -> m (Chunk a) #

Eq a => Eq (Chunk a) # 

Methods

(==) :: Chunk a -> Chunk a -> Bool #

(/=) :: Chunk a -> Chunk a -> Bool #

Ord a => Ord (Chunk a) # 

Methods

compare :: Chunk a -> Chunk a -> Ordering #

(<) :: Chunk a -> Chunk a -> Bool #

(<=) :: Chunk a -> Chunk a -> Bool #

(>) :: Chunk a -> Chunk a -> Bool #

(>=) :: Chunk a -> Chunk a -> Bool #

max :: Chunk a -> Chunk a -> Chunk a #

min :: Chunk a -> Chunk a -> Chunk a #

Show a => Show (Chunk a) # 

Methods

showsPrec :: Int -> Chunk a -> ShowS #

show :: Chunk a -> String #

showList :: [Chunk a] -> ShowS #

Generic (Chunk a) # 

Associated Types

type Rep (Chunk a) :: * -> * #

Methods

from :: Chunk a -> Rep (Chunk a) x #

to :: Rep (Chunk a) x -> Chunk a #

Monoid a => Monoid (Chunk a) #

Uses the underlying Monoid instances for the Style and for the particular _yarn. Therefore mempty will have no formatting and no colors and will generally have no text, though whether or not there is any text depends on the mempty for the type of the _yarn.

Methods

mempty :: Chunk a #

mappend :: Chunk a -> Chunk a -> Chunk a #

mconcat :: [Chunk a] -> Chunk a #

type Rep (Chunk a) # 
type Rep (Chunk a) = D1 (MetaData "Chunk" "Rainbow.Types" "rainbow-0.28.0.4-5DoLUaf2JtM7WNAQdkJiA9" False) (C1 (MetaCons "Chunk" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_scheme") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Scheme)) (S1 (MetaSel (Just Symbol "_yarn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a))))

chunk :: a -> Chunk a #

Creates a Chunk with no formatting and with the given text.

yarn :: Functor f => (t -> f a) -> Chunk t -> f (Chunk a) #

scheme :: Functor f => (Scheme -> f Scheme) -> Chunk a -> f (Chunk a) #

data Radiant #

Stores colors that may affect 8-color terminals, 256-color terminals, both, or neither.

Constructors

Radiant 

Instances

Eq Radiant # 

Methods

(==) :: Radiant -> Radiant -> Bool #

(/=) :: Radiant -> Radiant -> Bool #

Ord Radiant # 
Show Radiant # 
Generic Radiant # 

Associated Types

type Rep Radiant :: * -> * #

Methods

from :: Radiant -> Rep Radiant x #

to :: Rep Radiant x -> Radiant #

Monoid Radiant #

Uses the underlying Monoid instance for the Colors. Thus the last non-Nothing Color is used. This can be useful to specify one color for 8-color terminals and a different color for 256-color terminals.

type Rep Radiant # 
type Rep Radiant = D1 (MetaData "Radiant" "Rainbow.Types" "rainbow-0.28.0.4-5DoLUaf2JtM7WNAQdkJiA9" False) (C1 (MetaCons "Radiant" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "_color8") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Color Enum8))) (S1 (MetaSel (Just Symbol "_color256") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Color Word8)))))

color8 :: Functor f => (Color Enum8 -> f (Color Enum8)) -> Radiant -> f Radiant #