-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A simple and fast bytestring packer
--
@package bspack
@version 0.0.2
-- | Copyright : Copyright © 2014 Nicolas DI PRIMA
--
-- Maintainer : Nicolas DI PRIMA nicolas@di-prima.fr Stability :
-- experimental Portability : unknown
--
-- Simple ByteString packer
module Data.ByteString.Pack
-- | Simple Bytestring Packer
data Packer a
-- | Packing result:
--
--
-- - PackerOK a -> means the bytestring has been filled with the
-- given data
-- - PackerMore a cache -> a temporary
--
data Result a
PackerMore :: a -> Cache -> Result a
PackerFail :: String -> Result a
-- | pack the given packer into the given bytestring
pack :: Packer a -> Int -> Either String ByteString
-- | put a storable from the current position in the stream
putStorable :: Storable storable => storable -> Packer ()
-- | put a Bytestring from the current position in the stream
--
-- If the ByteString ins null, then do nothing
putByteString :: ByteString -> Packer ()
-- | Will put the given storable list from the current position in the
-- stream to the end.
--
-- This function will fail with not enough storage if the given storable
-- can't be written (not enough space)
--
-- example: > pack (fillList $ [1..] :: Word8) 9 ==> "123456789"
-- > pack (fillList $ [1..] :: Word32) 4 ==> "1000" > pack
-- (fillList $ [1..] :: Word32) 64 -- will work > pack (fillList $
-- [1..] :: Word32) 1 -- will fail (not enough space) > pack (fillList
-- $ [1..] :: Word32) 131 -- will fail (not enough space)
fillList :: Storable storable => [storable] -> Packer ()
-- | fill up from the current position in the stream to the end
--
-- it is basically: > fillUpWith s == fillList (repeat s)
fillUpWith :: Storable storable => storable -> Packer ()
-- | put Word8 in the current position in the stream
putWord8 :: Word8 -> Packer ()
-- | put Word16 in the current position in the stream /! use Host
-- Endianness
putWord16 :: Word16 -> Packer ()
-- | put Word32 in the current position in the stream /! use Host
-- Endianness
putWord32 :: Word32 -> Packer ()
-- | skip some bytes from the current position in the stream
skip :: Int -> Packer ()
-- | skip the size of a storable from the current position in the stream
skipStorable :: Storable storable => storable -> Packer ()
instance Show a => Show (Result a)
instance Monad Packer
instance Applicative Packer
instance Functor Packer
instance Show Cache