precursor-0.1.0.0: Prelude replacement

Safe HaskellNone
LanguageHaskell2010

Precursor.Text.Show

Synopsis

Documentation

class TextShow a where #

Conversion of values to Text. Because there are both strict and lazy Text variants, the TextShow class deliberately avoids using Text in its functions. Instead, showbPrec, showb, and showbList all return Builder, an efficient intermediate form that can be converted to either kind of Text.

Builder is a Monoid, so it is useful to use the mappend (or <>) function to combine Builders when creating TextShow instances. As an example:

import Data.Monoid
import TextShow

data Example = Example Int Int
instance TextShow Example where
    showb (Example i1 i2) = showb i1 <> showbSpace <> showb i2

If you do not want to create TextShow instances manually, you can alternatively use the TextShow.TH module to automatically generate default TextShow instances using Template Haskell, or the TextShow.Generic module to quickly define TextShow instances using genericShowbPrec.

Since: 2

Minimal complete definition

showbPrec | showb

Methods

showbPrec :: Int -> a -> Builder #

Convert a value to a Builder with the given predence.

Since: 2

showb :: a -> Builder #

Converts a value to a strict Text. If you hand-define this, it should satisfy:

showb = showbPrec 0

Since: 2

showbList :: [a] -> Builder #

Converts a list of values to a Builder. By default, this is defined as 'showbList = showbListWith showb, but it can be overridden to allow for specialized displaying of lists (e.g., lists of Chars).

Since: 2

showtPrec :: Int -> a -> Text #

Converts a value to a strict Text with the given precedence. This can be overridden for efficiency, but it should satisfy:

showtPrec p = toStrict . showtlPrec p

Since: 3

showt :: a -> Text #

Converts a value to a strict Text. This can be overridden for efficiency, but it should satisfy:

showt = showtPrec 0
showt = toStrict . showtl

The first equation is the default definition of showt.

Since: 3

showtList :: [a] -> Text #

Converts a list of values to a strict Text. This can be overridden for efficiency, but it should satisfy:

showtList = toStrict . showtlList

Since: 3

showtlPrec :: Int -> a -> Text #

Converts a value to a lazy Text with the given precedence. This can be overridden for efficiency, but it should satisfy:

showtlPrec p = toLazyText . showbPrec p

Since: 3

showtl :: a -> Text #

Converts a value to a lazy Text. This can be overridden for efficiency, but it should satisfy:

showtl = showtlPrec 0
showtl = toLazyText . showb

The first equation is the default definition of showtl.

Since: 3

showtlList :: [a] -> Text #

Converts a list of values to a lazy Text. This can be overridden for efficiency, but it should satisfy:

showtlList = toLazyText . showbList

Since: 3

Instances

TextShow ConType 
Show a => TextShow (FromStringShow a) 
TextShow a => TextShow (FromTextShow a) 
TextShow a => TextShow (Product a) # 
TextShow a => TextShow (Sum a) # 

Methods

showbPrec :: Int -> Sum a -> Builder #

showb :: Sum a -> Builder #

showbList :: [Sum a] -> Builder #

showtPrec :: Int -> Sum a -> Text #

showt :: Sum a -> Text #

showtList :: [Sum a] -> Text #

showtlPrec :: Int -> Sum a -> Text #

showtl :: Sum a -> Text #

showtlList :: [Sum a] -> Text #

(Show1 f, Show a) => TextShow (FromStringShow1 * f a)

Not available if using transformers-0.4

(TextShow1 f, TextShow a) => TextShow (FromTextShow1 * f a) 
(Show2 f, Show a, Show b) => TextShow (FromStringShow2 * * f a b)

Not available if using transformers-0.4

(TextShow2 f, TextShow a, TextShow b) => TextShow (FromTextShow2 * * f a b) 

show :: TextShow a => a -> Text Source #

print :: (TextShow a, MonadIO m) => a -> m () Source #