table-layout-1.0.0.0: Format tabular data as grid or table.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Layout.Table.Cell.Formatted

Description

Provides formatting to an instance of Cell. For example, in a unix terminal one could use the following:

>>> buildCell (formatted "\ESC[31m" "Hello World!" "\ESC[0m") :: String
Hello World!

The text then appears in dull red.

More complex nested formatting can be achieved by using the Monoid instance.

Synopsis

Documentation

data Formatted a Source #

Instances

Instances details
Foldable Formatted Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

Methods

fold :: Monoid m => Formatted m -> m

foldMap :: Monoid m => (a -> m) -> Formatted a -> m

foldMap' :: Monoid m => (a -> m) -> Formatted a -> m

foldr :: (a -> b -> b) -> b -> Formatted a -> b

foldr' :: (a -> b -> b) -> b -> Formatted a -> b

foldl :: (b -> a -> b) -> b -> Formatted a -> b

foldl' :: (b -> a -> b) -> b -> Formatted a -> b

foldr1 :: (a -> a -> a) -> Formatted a -> a

foldl1 :: (a -> a -> a) -> Formatted a -> a

toList :: Formatted a -> [a]

null :: Formatted a -> Bool

length :: Formatted a -> Int

elem :: Eq a => a -> Formatted a -> Bool

maximum :: Ord a => Formatted a -> a

minimum :: Ord a => Formatted a -> a

sum :: Num a => Formatted a -> a

product :: Num a => Formatted a -> a

Traversable Formatted Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

Methods

traverse :: Applicative f => (a -> f b) -> Formatted a -> f (Formatted b)

sequenceA :: Applicative f => Formatted (f a) -> f (Formatted a)

mapM :: Monad m => (a -> m b) -> Formatted a -> m (Formatted b)

sequence :: Monad m => Formatted (m a) -> m (Formatted a)

Functor Formatted Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

Methods

fmap :: (a -> b) -> Formatted a -> Formatted b

(<$) :: a -> Formatted b -> Formatted a

IsString a => IsString (Formatted a) Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

Methods

fromString :: String -> Formatted a

Monoid (Formatted a) Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

Semigroup (Formatted a) Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

Methods

(<>) :: Formatted a -> Formatted a -> Formatted a

sconcat :: NonEmpty (Formatted a) -> Formatted a

stimes :: Integral b => b -> Formatted a -> Formatted a

Show a => Show (Formatted a) Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

Methods

showsPrec :: Int -> Formatted a -> ShowS

show :: Formatted a -> String

showList :: [Formatted a] -> ShowS

Eq a => Eq (Formatted a) Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

Methods

(==) :: Formatted a -> Formatted a -> Bool

(/=) :: Formatted a -> Formatted a -> Bool

Cell a => Cell (Formatted a) Source # 
Instance details

Defined in Text.Layout.Table.Cell.Formatted

plain :: a -> Formatted a Source #

Create a value from content that is kept plain without any formatting.

formatted Source #

Arguments

:: String

Prefix text directives for formatting.

-> Formatted a

The content to be formatted.

-> String

Suffix text directives for formatting.

-> Formatted a 

Create a formatted value with formatting directives that are applied to the whole value. The actual formatting has to be done by the backend.

mapAffix Source #

Arguments

:: (String -> String)

Function to operate on prefix text directives.

-> (String -> String)

Function to operate on suffix text directives.

-> Formatted a

The formatted value to operate on.

-> Formatted a 

Map over the formatting directives of a formatted value.

cataFormatted Source #

Arguments

:: b

Value of Empty.

-> ([b] -> b)

Function for operating over Concat.

-> (a -> b)

Function for operating over Plain.

-> (String -> b -> String -> b)

Function for operating over Format.

-> Formatted a 
-> b 

Process a formatted value to produce an arbitrary value. This is the catamorphism for Formatted.