bytestring-show-0.3.5.6: Efficient conversion of values into readable byte strings.

Copyright | (c) 2008 Dan Doel
Maintainer | Dan Doel
Stability | Experimental
Portability | Non-portable (type synonym instances)
Safe Haskell | None
Language | Haskell98

Text.Show.ByteString

Contents

- The Show class
- Putting Chars
- Putting Strings
- Putting digits
- Putting integers
- Putting floats
- Combining builders
- Printing values
- Put

Description

Efficiently convert from values to lazy byte strings.

Synopsis

- class Show a where
- show :: Show a => a -> ByteString
- putAscii :: Char -> Put
- putUTF8 :: Char -> Put
- putAsciiStr :: String -> Put
- putUTF8Str :: String -> Put
- unsafePutDigit :: Int -> Put
- putDigit :: Int -> Put
- showpIntAtBase :: Integral a => a -> (Int -> Char) -> a -> Put
- showpGFloat :: RealFloat a => Maybe Int -> a -> Put
- showpFFloat :: RealFloat a => Maybe Int -> a -> Put
- showpEFloat :: RealFloat a => Maybe Int -> a -> Put
- unlinesP :: [Put] -> Put
- unwordsP :: [Put] -> Put
- showpParen :: Bool -> Put -> Put
- print :: Show a => a -> IO ()
- type Put = PutM ()
- newtype PutM a :: * -> * = Put {
  - unPut :: PairS a
  }
- runPut :: Put -> ByteString

# The Show class

class Show a where Source #

Conversion of values to readable byte strings. Minimal complete definition: `showp` or `showpPrec`

Methods

showpPrec :: Int -> a -> Put Source #

Encodes a value to an efficient byte string builder. The precedence is used to determine where to put parentheses in a shown expression involving operators.

Values of type Put can be efficiently combined, so the showp functions are available for showing multiple values before producing an output byte string.

showp :: a -> Put Source #

Encodes a value to an efficient byte string builder. Values of type Put can be efficiently combined, so this is available for building strings from multiple values.

showpList :: [a] -> Put Source #

Allows for specialized display of lists of values. This is used, for example, when showing arrays of Chars.

Instances

Show Bool Source # |
Methods showpPrec :: Int -> Bool -> Put Source # showp :: Bool -> Put Source # showpList :: [Bool] -> Put Source #
Show Char Source # |
Methods showpPrec :: Int -> Char -> Put Source # showp :: Char -> Put Source # showpList :: [Char] -> Put Source #
Show Double Source # |
Methods showpPrec :: Int -> Double -> Put Source # showp :: Double -> Put Source # showpList :: [Double] -> Put Source #
Show Float Source # |
Methods showpPrec :: Int -> Float -> Put Source # showp :: Float -> Put Source # showpList :: [Float] -> Put Source #
Show Int Source # |
Methods showpPrec :: Int -> Int -> Put Source # showp :: Int -> Put Source # showpList :: [Int] -> Put Source #
Show Int8 Source # |
Methods showpPrec :: Int -> Int8 -> Put Source # showp :: Int8 -> Put Source # showpList :: [Int8] -> Put Source #
Show Int16 Source # |
Methods showpPrec :: Int -> Int16 -> Put Source # showp :: Int16 -> Put Source # showpList :: [Int16] -> Put Source #
Show Int32 Source # |
Methods showpPrec :: Int -> Int32 -> Put Source # showp :: Int32 -> Put Source # showpList :: [Int32] -> Put Source #
Show Int64 Source # |
Methods showpPrec :: Int -> Int64 -> Put Source # showp :: Int64 -> Put Source # showpList :: [Int64] -> Put Source #
Show Integer Source # |
Methods showpPrec :: Int -> Integer -> Put Source # showp :: Integer -> Put Source # showpList :: [Integer] -> Put Source #
Show Ordering Source # |
Methods showpPrec :: Int -> Ordering -> Put Source # showp :: Ordering -> Put Source # showpList :: [Ordering] -> Put Source #
Show Word Source # |
Methods showpPrec :: Int -> Word -> Put Source # showp :: Word -> Put Source # showpList :: [Word] -> Put Source #
Show Word8 Source # |
Methods showpPrec :: Int -> Word8 -> Put Source # showp :: Word8 -> Put Source # showpList :: [Word8] -> Put Source #
Show Word16 Source # |
Methods showpPrec :: Int -> Word16 -> Put Source # showp :: Word16 -> Put Source # showpList :: [Word16] -> Put Source #
Show Word32 Source # |
Methods showpPrec :: Int -> Word32 -> Put Source # showp :: Word32 -> Put Source # showpList :: [Word32] -> Put Source #
Show Word64 Source # |
Methods showpPrec :: Int -> Word64 -> Put Source # showp :: Word64 -> Put Source # showpList :: [Word64] -> Put Source #
Show () Source # |
Methods showpPrec :: Int -> () -> Put Source # showp :: () -> Put Source # showpList :: [()] -> Put Source #
Show Put Source # |
Methods showpPrec :: Int -> Put -> Put Source # showp :: Put -> Put Source # showpList :: [Put] -> Put Source #
Show a => Show [a] Source # |
Methods showpPrec :: Int -> [a] -> Put Source # showp :: [a] -> Put Source # showpList :: [[a]] -> Put Source #
Show a => Show (Maybe a) Source # |
Methods showpPrec :: Int -> Maybe a -> Put Source # showp :: Maybe a -> Put Source # showpList :: [Maybe a] -> Put Source #
(Show a, Integral a) => Show (Ratio a) Source # |
Methods showpPrec :: Int -> Ratio a -> Put Source # showp :: Ratio a -> Put Source # showpList :: [Ratio a] -> Put Source #
(Show a, RealFloat a) => Show (Complex a) Source # |
Methods showpPrec :: Int -> Complex a -> Put Source # showp :: Complex a -> Put Source # showpList :: [Complex a] -> Put Source #
Show e => Show (Set e) Source # |
Methods showpPrec :: Int -> Set e -> Put Source # showp :: Set e -> Put Source # showpList :: [Set e] -> Put Source #
(Show a, Show b) => Show (Either a b) Source # |
Methods showpPrec :: Int -> Either a b -> Put Source # showp :: Either a b -> Put Source # showpList :: [Either a b] -> Put Source #
(Show a, Show b) => Show (a, b) Source # |
Methods showpPrec :: Int -> (a, b) -> Put Source # showp :: (a, b) -> Put Source # showpList :: [(a, b)] -> Put Source #
(Show i, Show e, Ix i) => Show (Array i e) Source # |
Methods showpPrec :: Int -> Array i e -> Put Source # showp :: Array i e -> Put Source # showpList :: [Array i e] -> Put Source #
(Show k, Show v) => Show (Map k v) Source # |
Methods showpPrec :: Int -> Map k v -> Put Source # showp :: Map k v -> Put Source # showpList :: [Map k v] -> Put Source #
(Show a, Show b, Show c) => Show (a, b, c) Source # |
Methods showpPrec :: Int -> (a, b, c) -> Put Source # showp :: (a, b, c) -> Put Source # showpList :: [(a, b, c)] -> Put Source #
(Show a, Show b, Show c, Show d) => Show (a, b, c, d) Source # |
Methods showpPrec :: Int -> (a, b, c, d) -> Put Source # showp :: (a, b, c, d) -> Put Source # showpList :: [(a, b, c, d)] -> Put Source #
(Show a, Show b, Show c, Show d, Show e) => Show (a, b, c, d, e) Source # |
Methods showpPrec :: Int -> (a, b, c, d, e) -> Put Source # showp :: (a, b, c, d, e) -> Put Source # showpList :: [(a, b, c, d, e)] -> Put Source #
(Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f) Source # |
Methods showpPrec :: Int -> (a, b, c, d, e, f) -> Put Source # showp :: (a, b, c, d, e, f) -> Put Source # showpList :: [(a, b, c, d, e, f)] -> Put Source #
(Show a, Show b, Show c, Show d, Show e, Show f, Show g) => Show (a, b, c, d, e, f, g) Source # |
Methods showpPrec :: Int -> (a, b, c, d, e, f, g) -> Put Source # showp :: (a, b, c, d, e, f, g) -> Put Source # showpList :: [(a, b, c, d, e, f, g)] -> Put Source #

show :: Show a => a -> ByteString Source #

Encode a single value into a byte string

# Putting Chars

putAscii :: Char -> Put Source #

Writes a single Char to a byte string, assuming it's ascii.

putUTF8 :: Char -> Put Source #

Writes a single Char to a byte string, properly UTF-8 encoded

# Putting Strings

putAsciiStr :: String -> Put Source #

Writes a string of ascii characters to a byte string

putUTF8Str :: String -> Put Source #

Writes a string of unicode characters to a byte string, properly UTF-8 encoded

# Putting digits

unsafePutDigit :: Int -> Put Source #

Puts the decimal digit corresponding to the given Int without checking that it is in the interval [0,9]

putDigit :: Int -> Put Source #

Puts the digit corresponding to the Int passed in.

# Putting integers

showpIntAtBase :: Integral a => a -> (Int -> Char) -> a -> Put Source #

Shows an Integral number using the base specified by the first argument and the chracter representation specified by the second.

# Putting floats

showpGFloat :: RealFloat a => Maybe Int -> a -> Put Source #

Show a signed RealFloat value using decimal notation when the absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise. The optional integer can be used to specify precision.

showpFFloat :: RealFloat a => Maybe Int -> a -> Put Source #

Show a signed RealFloat value using decimal notation. The optional integer can be used to specify precision.

showpEFloat :: RealFloat a => Maybe Int -> a -> Put Source #

Show a signed RealFloat value using scientific (exponential) notation. The optional integer can be used to specify precision.

# Combining builders

unlinesP :: [Put] -> Put Source #

Merge several string builders, separating them by newlines

unwordsP :: [Put] -> Put Source #

Merge several string builders, separating them by spaces

showpParen :: Bool -> Put -> Put Source #

A utility function for surrounding output by parentheses conditionally.

# Printing values

print :: Show a => a -> IO () Source #

Print a value to the standard output

# Put

type Put = PutM () #

Put merely lifts Builder into a Writer monad, applied to ().

newtype PutM a :: * -> * #

The PutM type. A Writer monad over the efficient Builder monoid.

Constructors

Put |

Fields

- unPut :: PairS a

Instances

Monad PutM |
Methods (>>=) :: PutM a -> (a -> PutM b) -> PutM b # (>>) :: PutM a -> PutM b -> PutM b # return :: a -> PutM a # fail :: String -> PutM a #
Functor PutM |
Methods fmap :: (a -> b) -> PutM a -> PutM b # (<$) :: a -> PutM b -> PutM a #
Applicative PutM |
Methods pure :: a -> PutM a # (<*>) :: PutM (a -> b) -> PutM a -> PutM b # (*>) :: PutM a -> PutM b -> PutM b # (<*) :: PutM a -> PutM b -> PutM a #
Show Put Source # |
Methods showpPrec :: Int -> Put -> Put Source # showp :: Put -> Put Source # showpList :: [Put] -> Put Source #
Semigroup (PutM ()) |
Methods (<>) :: PutM () -> PutM () -> PutM () # sconcat :: NonEmpty (PutM ()) -> PutM () # stimes :: Integral b => b -> PutM () -> PutM () #
Monoid (PutM ()) |
Methods mempty :: PutM () # mappend :: PutM () -> PutM () -> PutM () # mconcat :: [PutM ()] -> PutM () #

runPut :: Put -> ByteString #

Run the `Put` monad with a serialiser