rainbow-0.30.0.2: 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 # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Foldable Color # 
Instance details

Defined in Rainbow.Types

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 # 
Instance details

Defined in Rainbow.Types

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) # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Ord a => Ord (Color a) # 
Instance details

Defined in Rainbow.Types

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) # 
Instance details

Defined in Rainbow.Types

Methods

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

show :: Color a -> String #

showList :: [Color a] -> ShowS #

Generic (Color a) # 
Instance details

Defined in Rainbow.Types

Associated Types

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

Methods

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

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

Semigroup (Color a) # 
Instance details

Defined in Rainbow.Types

Methods

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

sconcat :: NonEmpty (Color a) -> Color a #

stimes :: Integral b => b -> Color a -> Color a #

Monoid (Color a) #

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

Instance details

Defined in Rainbow.Types

Methods

mempty :: Color a #

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

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

type Rep (Color a) # 
Instance details

Defined in Rainbow.Types

type Rep (Color a) = D1 (MetaData "Color" "Rainbow.Types" "rainbow-0.30.0.2-49gJ0qFpne0BeWIyzuRGh1" True) (C1 (MetaCons "Color" PrefixI False) (S1 (MetaSel (Nothing :: Maybe 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 # 
Instance details

Defined in Rainbow.Types

Enum Enum8 # 
Instance details

Defined in Rainbow.Types

Eq Enum8 # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Ord Enum8 # 
Instance details

Defined in Rainbow.Types

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 # 
Instance details

Defined in Rainbow.Types

Methods

showsPrec :: Int -> Enum8 -> ShowS #

show :: Enum8 -> String #

showList :: [Enum8] -> ShowS #

Generic Enum8 # 
Instance details

Defined in Rainbow.Types

Associated Types

type Rep Enum8 :: Type -> Type #

Methods

from :: Enum8 -> Rep Enum8 x #

to :: Rep Enum8 x -> Enum8 #

type Rep Enum8 # 
Instance details

Defined in Rainbow.Types

type Rep Enum8 = D1 (MetaData "Enum8" "Rainbow.Types" "rainbow-0.30.0.2-49gJ0qFpne0BeWIyzuRGh1" False) (((C1 (MetaCons "E0" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "E1" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "E2" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "E3" PrefixI False) (U1 :: Type -> Type))) :+: ((C1 (MetaCons "E4" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "E5" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "E6" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "E7" PrefixI False) (U1 :: Type -> Type))))

data Format #

Text formatting such as bold, italic, etc.

Constructors

Format 
Instances
Eq Format # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Ord Format # 
Instance details

Defined in Rainbow.Types

Show Format # 
Instance details

Defined in Rainbow.Types

Generic Format # 
Instance details

Defined in Rainbow.Types

Associated Types

type Rep Format :: Type -> Type #

Methods

from :: Format -> Rep Format x #

to :: Rep Format x -> Format #

Semigroup Format # 
Instance details

Defined in Rainbow.Types

Monoid Format #

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

Instance details

Defined in Rainbow.Types

type Rep Format # 
Instance details

Defined in Rainbow.Types

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 # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Foldable Style # 
Instance details

Defined in Rainbow.Types

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 # 
Instance details

Defined in Rainbow.Types

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) # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Ord a => Ord (Style a) # 
Instance details

Defined in Rainbow.Types

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) # 
Instance details

Defined in Rainbow.Types

Methods

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

show :: Style a -> String #

showList :: [Style a] -> ShowS #

Generic (Style a) # 
Instance details

Defined in Rainbow.Types

Associated Types

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

Methods

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

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

Semigroup (Style a) # 
Instance details

Defined in Rainbow.Types

Methods

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

sconcat :: NonEmpty (Style a) -> Style a #

stimes :: Integral b => b -> Style a -> Style a #

Monoid (Style a) #

Uses the underlying Monoid instances for Color and Format.

Instance details

Defined in Rainbow.Types

Methods

mempty :: Style a #

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

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

type Rep (Style a) # 
Instance details

Defined in Rainbow.Types

type Rep (Style a) = D1 (MetaData "Style" "Rainbow.Types" "rainbow-0.30.0.2-49gJ0qFpne0BeWIyzuRGh1" False) (C1 (MetaCons "Style" PrefixI True) (S1 (MetaSel (Just "_fore") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Color a)) :*: (S1 (MetaSel (Just "_back") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Color a)) :*: S1 (MetaSel (Just "_format") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Format))))

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 # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Ord Scheme # 
Instance details

Defined in Rainbow.Types

Show Scheme # 
Instance details

Defined in Rainbow.Types

Generic Scheme # 
Instance details

Defined in Rainbow.Types

Associated Types

type Rep Scheme :: Type -> Type #

Methods

from :: Scheme -> Rep Scheme x #

to :: Rep Scheme x -> Scheme #

Semigroup Scheme # 
Instance details

Defined in Rainbow.Types

Monoid Scheme # 
Instance details

Defined in Rainbow.Types

type Rep Scheme # 
Instance details

Defined in Rainbow.Types

type Rep Scheme = D1 (MetaData "Scheme" "Rainbow.Types" "rainbow-0.30.0.2-49gJ0qFpne0BeWIyzuRGh1" False) (C1 (MetaCons "Scheme" PrefixI True) (S1 (MetaSel (Just "_style8") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Style Enum8)) :*: S1 (MetaSel (Just "_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 # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Foldable Chunk # 
Instance details

Defined in Rainbow.Types

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 # 
Instance details

Defined in Rainbow.Types

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) # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Ord a => Ord (Chunk a) # 
Instance details

Defined in Rainbow.Types

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) # 
Instance details

Defined in Rainbow.Types

Methods

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

show :: Chunk a -> String #

showList :: [Chunk a] -> ShowS #

Generic (Chunk a) # 
Instance details

Defined in Rainbow.Types

Associated Types

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

Methods

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

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

Semigroup a => Semigroup (Chunk a) # 
Instance details

Defined in Rainbow.Types

Methods

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

sconcat :: NonEmpty (Chunk a) -> Chunk a #

stimes :: Integral b => b -> Chunk a -> 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.

Instance details

Defined in Rainbow.Types

Methods

mempty :: Chunk a #

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

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

type Rep (Chunk a) # 
Instance details

Defined in Rainbow.Types

type Rep (Chunk a) = D1 (MetaData "Chunk" "Rainbow.Types" "rainbow-0.30.0.2-49gJ0qFpne0BeWIyzuRGh1" False) (C1 (MetaCons "Chunk" PrefixI True) (S1 (MetaSel (Just "_scheme") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Scheme) :*: S1 (MetaSel (Just "_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 # 
Instance details

Defined in Rainbow.Types

Methods

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

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

Ord Radiant # 
Instance details

Defined in Rainbow.Types

Show Radiant # 
Instance details

Defined in Rainbow.Types

Generic Radiant # 
Instance details

Defined in Rainbow.Types

Associated Types

type Rep Radiant :: Type -> Type #

Methods

from :: Radiant -> Rep Radiant x #

to :: Rep Radiant x -> Radiant #

Semigroup Radiant # 
Instance details

Defined in Rainbow.Types

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.

Instance details

Defined in Rainbow.Types

type Rep Radiant # 
Instance details

Defined in Rainbow.Types

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

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