bytestring-conversion-0.3.2: Type-classes to convert values to and from ByteString.

Safe Haskell | None
Language | Haskell2010

Data.ByteString.Conversion

Synopsis

- class ToByteString a where
  - builder :: a -> Builder
- class FromByteString a where
  - parser :: Parser a
- newtype Hex a = Hex {
  - fromHex :: a
  }
- newtype List a = List {
  - fromList :: [a]
  }
- toByteString :: ToByteString a => a -> ByteString
- toByteString' :: ToByteString a => a -> ByteString
- runBuilder :: Builder -> ByteString
- fromByteString :: FromByteString a => ByteString -> Maybe a
- fromByteString' :: FromByteString a => ByteString -> Maybe a
- runParser :: Parser a -> ByteString -> Either String a
- runParser' :: Parser a -> ByteString -> Either String a

# Documentation

class ToByteString a where Source #

Methods

builder :: a -> Builder Source #

#### Instances

Instances details

ToByteString Builder Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Builder -> Builder Source #
ToByteString ByteString Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: ByteString -> Builder Source #
ToByteString ByteString Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: ByteString -> Builder Source #
ToByteString Int16 Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Int16 -> Builder Source #
ToByteString Int32 Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Int32 -> Builder Source #
ToByteString Int64 Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Int64 -> Builder Source #
ToByteString Int8 Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Int8 -> Builder Source #
ToByteString Word16 Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Word16 -> Builder Source #
ToByteString Word32 Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Word32 -> Builder Source #
ToByteString Word64 Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Word64 -> Builder Source #
ToByteString Word8 Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Word8 -> Builder Source #
ToByteString Text Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Text -> Builder Source #
ToByteString Text Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Text -> Builder Source #
ToByteString Integer Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Integer -> Builder Source #
ToByteString Bool Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Bool -> Builder Source #
ToByteString Char Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Char -> Builder Source #
ToByteString Double Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Double -> Builder Source #
ToByteString Float Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Float -> Builder Source #
ToByteString Int Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Int -> Builder Source #
ToByteString Word Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Word -> Builder Source #
ToByteString (Hex Int16) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int16 -> Builder Source #
ToByteString (Hex Int32) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int32 -> Builder Source #
ToByteString (Hex Int64) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int64 -> Builder Source #
ToByteString (Hex Int8) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int8 -> Builder Source #
ToByteString (Hex Word16) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word16 -> Builder Source #
ToByteString (Hex Word32) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word32 -> Builder Source #
ToByteString (Hex Word64) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word64 -> Builder Source #
ToByteString (Hex Word8) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word8 -> Builder Source #
ToByteString (Hex Int) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int -> Builder Source #
ToByteString (Hex Word) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word -> Builder Source #
ToByteString a => ToByteString (List a) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: List a -> Builder Source #
ToByteString a => ToByteString (CI a) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: CI a -> Builder Source #
ToByteString [Char] Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: [Char] -> Builder Source #

class FromByteString a where Source #

Parse `ByteString`s.

Methods

parser :: Parser a Source #

#### Instances

Instances details

FromByteString ByteString Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser ByteString Source #
FromByteString ByteString Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser ByteString Source #
FromByteString Int16 Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Int16 Source #
FromByteString Int32 Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Int32 Source #
FromByteString Int64 Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Int64 Source #
FromByteString Int8 Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Int8 Source #
FromByteString Word16 Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Word16 Source #
FromByteString Word32 Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Word32 Source #
FromByteString Word64 Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Word64 Source #
FromByteString Word8 Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Word8 Source #
FromByteString Text Source # | UTF-8 is assumed as encoding format.
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Text Source #
FromByteString Text Source # | UTF-8 is assumed as encoding format.
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Text Source #
FromByteString Integer Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Integer Source #
FromByteString Bool Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Bool Source #
FromByteString Char Source # | UTF-8 is assumed as encoding format.
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Char Source #
FromByteString Double Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Double Source #
FromByteString Int Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Int Source #
FromByteString Word Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser Word Source #
(Integral a, Bits a) => FromByteString (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser (Hex a) Source #
FromByteString a => FromByteString (List a) Source # | A (flat) comma-separated list of values without spaces.
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser (List a) Source #
(FoldCase a, FromByteString a) => FromByteString (CI a) Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser (CI a) Source #
FromByteString [Char] Source # | UTF-8 is assumed as encoding format.
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser [Char] Source #

newtype Hex a Source #

Newtype wrapper to parse and produce integral numbers in hexadecimal format

Constructors

Hex |

Fields

- fromHex :: a

#### Instances

Instances details

PrintfArg a => PrintfArg (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods formatArg :: Hex a -> FieldFormatter Source # parseFormat :: Hex a -> ModifierParser Source #
(Integral a, Bits a) => FromByteString (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser (Hex a) Source #
ToByteString (Hex Int16) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int16 -> Builder Source #
ToByteString (Hex Int32) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int32 -> Builder Source #
ToByteString (Hex Int64) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int64 -> Builder Source #
ToByteString (Hex Int8) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int8 -> Builder Source #
ToByteString (Hex Word16) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word16 -> Builder Source #
ToByteString (Hex Word32) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word32 -> Builder Source #
ToByteString (Hex Word64) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word64 -> Builder Source #
ToByteString (Hex Word8) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word8 -> Builder Source #
ToByteString (Hex Int) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Int -> Builder Source #
ToByteString (Hex Word) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: Hex Word -> Builder Source #
Bits a => Bits (Hex a) Source # |

Instance details

Defined in Data.ByteString.Conversion.Internal

Methods

(.&.) :: Hex a -> Hex a -> Hex a Source #

(.|.) :: Hex a -> Hex a -> Hex a Source #

xor :: Hex a -> Hex a -> Hex a Source #

complement :: Hex a -> Hex a Source #

shift :: Hex a -> Int -> Hex a Source #

rotate :: Hex a -> Int -> Hex a Source #

zeroBits :: Hex a Source #

bit :: Int -> Hex a Source #

setBit :: Hex a -> Int -> Hex a Source #

clearBit :: Hex a -> Int -> Hex a Source #

complementBit :: Hex a -> Int -> Hex a Source #

testBit :: Hex a -> Int -> Bool Source #

bitSizeMaybe :: Hex a -> Maybe Int Source #

bitSize :: Hex a -> Int Source #

isSigned :: Hex a -> Bool Source #

shiftL :: Hex a -> Int -> Hex a Source #

unsafeShiftL :: Hex a -> Int -> Hex a Source #

shiftR :: Hex a -> Int -> Hex a Source #

unsafeShiftR :: Hex a -> Int -> Hex a Source #

rotateL :: Hex a -> Int -> Hex a Source #

rotateR :: Hex a -> Int -> Hex a Source #

popCount :: Hex a -> Int Source #

Bounded a => Bounded (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods minBound :: Hex a Source # maxBound :: Hex a Source #
Enum a => Enum (Hex a) Source # |

Instance details

Defined in Data.ByteString.Conversion.Internal

Methods

succ :: Hex a -> Hex a Source #

pred :: Hex a -> Hex a Source #

toEnum :: Int -> Hex a Source #

fromEnum :: Hex a -> Int Source #

enumFrom :: Hex a -> [Hex a] Source #

enumFromThen :: Hex a -> Hex a -> [Hex a] Source #

enumFromTo :: Hex a -> Hex a -> [Hex a] Source #

enumFromThenTo :: Hex a -> Hex a -> Hex a -> [Hex a] Source #

Num a => Num (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods (+) :: Hex a -> Hex a -> Hex a Source # (-) :: Hex a -> Hex a -> Hex a Source # (*) :: Hex a -> Hex a -> Hex a Source # negate :: Hex a -> Hex a Source # abs :: Hex a -> Hex a Source # signum :: Hex a -> Hex a Source # fromInteger :: Integer -> Hex a Source #
Read a => Read (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods readsPrec :: Int -> ReadS (Hex a) Source # readList :: ReadS [Hex a] Source # readPrec :: ReadPrec (Hex a) Source # readListPrec :: ReadPrec [Hex a] Source #
Integral a => Integral (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods quot :: Hex a -> Hex a -> Hex a Source # rem :: Hex a -> Hex a -> Hex a Source # div :: Hex a -> Hex a -> Hex a Source # mod :: Hex a -> Hex a -> Hex a Source # quotRem :: Hex a -> Hex a -> (Hex a, Hex a) Source # divMod :: Hex a -> Hex a -> (Hex a, Hex a) Source # toInteger :: Hex a -> Integer Source #
Real a => Real (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods toRational :: Hex a -> Rational Source #
Show a => Show (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods showsPrec :: Int -> Hex a -> ShowS Source # show :: Hex a -> String Source # showList :: [Hex a] -> ShowS Source #
Eq a => Eq (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods (==) :: Hex a -> Hex a -> Bool Source # (/=) :: Hex a -> Hex a -> Bool Source #
Ord a => Ord (Hex a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods compare :: Hex a -> Hex a -> Ordering Source # (<) :: Hex a -> Hex a -> Bool Source # (<=) :: Hex a -> Hex a -> Bool Source # (>) :: Hex a -> Hex a -> Bool Source # (>=) :: Hex a -> Hex a -> Bool Source # max :: Hex a -> Hex a -> Hex a Source # min :: Hex a -> Hex a -> Hex a Source #

newtype List a Source #

Newtype wrapper to parse and produce a comma separated list of values.

Constructors

List |

Fields

- fromList :: [a]

#### Instances

Instances details

Applicative List Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods pure :: a -> List a Source # (<*>) :: List (a -> b) -> List a -> List b Source # liftA2 :: (a -> b -> c) -> List a -> List b -> List c Source # (*>) :: List a -> List b -> List b Source # (<*) :: List a -> List b -> List a Source #
Functor List Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods fmap :: (a -> b) -> List a -> List b Source # (<$) :: a -> List b -> List a Source #
Monad List Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods (>>=) :: List a -> (a -> List b) -> List b Source # (>>) :: List a -> List b -> List b Source # return :: a -> List a Source #
FromByteString a => FromByteString (List a) Source # | A (flat) comma-separated list of values without spaces.
Instance details Defined in Data.ByteString.Conversion.From Methods parser :: Parser (List a) Source #
ToByteString a => ToByteString (List a) Source # |
Instance details Defined in Data.ByteString.Conversion.To Methods builder :: List a -> Builder Source #
Show a => Show (List a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods showsPrec :: Int -> List a -> ShowS Source # show :: List a -> String Source # showList :: [List a] -> ShowS Source #
Eq a => Eq (List a) Source # |
Instance details Defined in Data.ByteString.Conversion.Internal Methods (==) :: List a -> List a -> Bool Source # (/=) :: List a -> List a -> Bool Source #

toByteString :: ToByteString a => a -> ByteString Source #

toByteString' :: ToByteString a => a -> ByteString Source #

Please note that this needs to convert from a lazy `ByteString` to a strict one which involves copying the whole string.

runBuilder :: Builder -> ByteString Source #

fromByteString :: FromByteString a => ByteString -> Maybe a Source #

fromByteString' :: FromByteString a => ByteString -> Maybe a Source #

runParser :: Parser a -> ByteString -> Either String a Source #

runParser' :: Parser a -> ByteString -> Either String a Source #