-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Abstractions for operations on pointers
--
-- Abstractions for operations on pointers
@package ptr
@version 0.16.8
module Ptr.IO
peekStorable :: Storable storable => Ptr Word8 -> IO storable
peekWord8 :: Ptr Word8 -> IO Word8
-- | Big-endian word of 2 bytes.
peekBEWord16 :: Ptr Word8 -> IO Word16
-- | Little-endian word of 2 bytes.
peekLEWord16 :: Ptr Word8 -> IO Word16
-- | Big-endian word of 4 bytes.
peekBEWord32 :: Ptr Word8 -> IO Word32
-- | Little-endian word of 4 bytes.
peekLEWord32 :: Ptr Word8 -> IO Word32
-- | Big-endian word of 8 bytes.
peekBEWord64 :: Ptr Word8 -> IO Word64
-- | Little-endian word of 8 bytes.
peekLEWord64 :: Ptr Word8 -> IO Word64
peekInt8 :: Ptr Word8 -> IO Int8
-- | Big-endian int of 2 bytes.
peekBEInt16 :: Ptr Word8 -> IO Int16
-- | Little-endian int of 2 bytes.
peekLEInt16 :: Ptr Word8 -> IO Int16
-- | Big-endian int of 4 bytes.
peekBEInt32 :: Ptr Word8 -> IO Int32
-- | Little-endian int of 4 bytes.
peekLEInt32 :: Ptr Word8 -> IO Int32
-- | Big-endian int of 8 bytes.
peekBEInt64 :: Ptr Word8 -> IO Int64
-- | Little-endian int of 8 bytes.
peekLEInt64 :: Ptr Word8 -> IO Int64
-- | Allocate a new byte array with memcpy.
peekBytes :: Ptr Word8 -> Int -> IO ByteString
peekShortByteString :: Ptr Word8 -> Int -> IO ShortByteString
peekNullTerminatedShortByteString :: Ptr Word8 -> (Int -> IO ShortByteString -> IO a) -> IO a
pokeStorable :: Storable a => Ptr Word8 -> a -> IO ()
pokeWord8 :: Ptr Word8 -> Word8 -> IO ()
pokeWord8Off :: Ptr Word8 -> Int -> Word8 -> IO ()
pokeBEWord16 :: Ptr Word8 -> Word16 -> IO ()
pokeBEWord32 :: Ptr Word8 -> Word32 -> IO ()
pokeBEWord64 :: Ptr Word8 -> Word64 -> IO ()
pokeLEWord16 :: Ptr Word8 -> Word16 -> IO ()
pokeLEWord32 :: Ptr Word8 -> Word32 -> IO ()
pokeLEWord64 :: Ptr Word8 -> Word64 -> IO ()
pokeBytesTrimming :: Ptr Word8 -> Int -> ByteString -> IO ()
pokeBytes :: Ptr Word8 -> ByteString -> IO ()
module Ptr.PokeAndPeek
-- | Encoder and decoder of the same binary representation.
--
-- You can compose both the covariant and contravariant parameters of
-- PokeAndPeek using Applicative and Profunctor. E.g.,
--
--
-- word8AndWord32 :: PokeAndPeek (Word8, Word32) (Word8, Word32)
-- word8AndWord32 =
-- (,) <$> lmap fst word8 <*> lmap snd beWord32
--
data PokeAndPeek input output
PokeAndPeek :: !Int -> (Ptr Word8 -> input -> IO ()) -> (Ptr Word8 -> IO output) -> PokeAndPeek input output
-- | A codec, which encodes and decodes the same type. E.g.,
--
--
-- word8AndWord32 :: InvPokeAndPeek (Word8, Word32)
-- word8AndWord32 =
-- (,) <$> lmap fst word8 <*> lmap snd beWord32
--
type InvPokeAndPeek value = PokeAndPeek value value
word8 :: InvPokeAndPeek Word8
leWord16 :: InvPokeAndPeek Word16
leWord32 :: InvPokeAndPeek Word32
leWord64 :: InvPokeAndPeek Word64
beWord16 :: InvPokeAndPeek Word16
beWord32 :: InvPokeAndPeek Word32
beWord64 :: InvPokeAndPeek Word64
bytes :: Int -> InvPokeAndPeek ByteString
instance Data.Profunctor.Unsafe.Profunctor Ptr.PokeAndPeek.PokeAndPeek
instance GHC.Base.Functor (Ptr.PokeAndPeek.PokeAndPeek input)
instance GHC.Base.Applicative (Ptr.PokeAndPeek.PokeAndPeek input)
module Ptr.Poke
-- | Specification of a sized and errorless writing action to a pointer.
data Poke input
Poke :: !Int -> !Ptr Word8 -> input -> IO () -> Poke input
word8 :: Poke Word8
leWord16 :: Poke Word16
leWord32 :: Poke Word32
leWord64 :: Poke Word64
beWord16 :: Poke Word16
beWord32 :: Poke Word32
beWord64 :: Poke Word64
bytes :: Int -> Poke ByteString
pokeAndPeek :: PokeAndPeek input output -> Poke input
asciiChar :: Poke Char
asciiDigit :: Poke Word8
asciiHexDigit :: Poke Word8
vector :: Int -> Poke element -> Poke (Vector element)
instance Data.Functor.Contravariant.Contravariant Ptr.Poke.Poke
instance Data.Functor.Contravariant.Divisible.Divisible Ptr.Poke.Poke
module Ptr.Poking
-- | An efficiently composable unmaterialised specification of how to
-- populate a pointer.
--
-- Once composed it can be materialized into a specific data-structure
-- like ByteString or to directly populate a pointer in some low-level
-- API.
data Poking
-- |
-- - Amount of bytes the encoded data will occupy.
-- - Exception-free action, which populates the pointer to the encoded
-- data.
--
Poking :: !Int -> (Ptr Word8 -> IO ()) -> Poking
null :: Poking -> Bool
length :: Poking -> Int
word8 :: Word8 -> Poking
leWord16 :: Word16 -> Poking
leWord32 :: Word32 -> Poking
leWord64 :: Word64 -> Poking
beWord16 :: Word16 -> Poking
beWord32 :: Word32 -> Poking
beWord64 :: Word64 -> Poking
bytes :: ByteString -> Poking
poke :: Poke input -> input -> Poking
pokeAndPeek :: PokeAndPeek input output -> input -> Poking
-- | Unsigned ASCII integral
asciiIntegral :: Integral a => a -> Poking
asciiChar :: Char -> Poking
asciiPaddedAndTrimmedIntegral :: Integral a => Int -> a -> Poking
asciiUtcTimeInIso8601 :: UTCTime -> Poking
list :: (element -> Poking) -> [element] -> Poking
vector :: Vector vector element => (element -> Poking) -> vector element -> Poking
intercalateVector :: Vector vector element => (element -> Poking) -> Poking -> vector element -> Poking
instance GHC.Base.Semigroup Ptr.Poking.Poking
instance GHC.Base.Monoid Ptr.Poking.Poking
instance Data.String.IsString Ptr.Poking.Poking
module Ptr.ParseUnbound
-- | Unbound parser, whose peeking action decides how much input to
-- consume, and merely informs the executor about how many bytes it
-- consumed.
newtype ParseUnbound output
ParseUnbound :: (Ptr Word8 -> forall result. (Text -> IO result) -> (output -> Int -> IO result) -> IO result) -> ParseUnbound output
fail :: Text -> ParseUnbound output
io :: Int -> (Ptr Word8 -> IO output) -> ParseUnbound output
pokeAndPeek :: PokeAndPeek input output -> ParseUnbound output
word8 :: ParseUnbound Word8
beWord16 :: ParseUnbound Word16
beWord32 :: ParseUnbound Word32
beWord64 :: ParseUnbound Word64
bytes :: Int -> ParseUnbound ByteString
nullTerminatedBytes :: ParseUnbound ByteString
nullTerminatedShortByteString :: ParseUnbound ShortByteString
bytesWhile :: (Word8 -> Bool) -> ParseUnbound ByteString
skipWhile :: (Word8 -> Bool) -> ParseUnbound ()
foldWhile :: (Word8 -> Bool) -> (state -> Word8 -> state) -> state -> ParseUnbound state
-- | Unsigned integral number encoded in ASCII.
unsignedASCIIIntegral :: Integral a => ParseUnbound a
instance GHC.Base.Functor Ptr.ParseUnbound.ParseUnbound
instance GHC.Base.Applicative Ptr.ParseUnbound.ParseUnbound
instance GHC.Base.Monad Ptr.ParseUnbound.ParseUnbound
module Ptr.Parse
newtype Parse output
Parse :: (Int -> Ptr Word8 -> forall result. (Int -> IO result) -> (Text -> IO result) -> (output -> Int -> Ptr Word8 -> IO result) -> IO result) -> Parse output
fail :: Text -> Parse output
io :: Int -> (Ptr Word8 -> IO output) -> Parse output
mapInIO :: (output -> IO newOutput) -> Parse output -> Parse newOutput
pokeAndPeek :: PokeAndPeek input output -> Parse output
limiting :: Int -> Parse output -> Parse output
-- | Decode the remaining bytes, whithout moving the parser's cursor.
-- Useful for debugging.
peekRemainders :: Parse ByteString
word8 :: Parse Word8
beWord16 :: Parse Word16
beWord32 :: Parse Word32
beWord64 :: Parse Word64
bytes :: Int -> Parse ByteString
allBytes :: Parse ByteString
nullTerminatedBytes :: Parse ByteString
nullTerminatedShortByteString :: Parse ShortByteString
bytesWhile :: (Word8 -> Bool) -> Parse ByteString
skipWhile :: (Word8 -> Bool) -> Parse ()
foldWhile :: (Word8 -> Bool) -> (state -> Word8 -> state) -> state -> Parse state
-- | Unsigned integral number encoded in ASCII.
unsignedASCIIIntegral :: Integral a => Parse a
instance GHC.Base.Functor Ptr.Parse.Parse
instance GHC.Base.Applicative Ptr.Parse.Parse
instance GHC.Base.Alternative Ptr.Parse.Parse
instance GHC.Base.Monad Ptr.Parse.Parse
instance GHC.Base.MonadPlus Ptr.Parse.Parse
instance Control.Monad.IO.Class.MonadIO Ptr.Parse.Parse
module Ptr.Peek
data Peek output
Peek :: {-# UNPACK #-} !Int -> !Ptr Word8 -> IO output -> Peek output
word8 :: Peek Word8
beWord16 :: Peek Word16
beWord32 :: Peek Word32
beWord64 :: Peek Word64
bytes :: Int -> Peek ByteString
shortByteString :: Int -> Peek ShortByteString
pokeAndPeek :: PokeAndPeek input output -> Peek output
-- | Given the length of the data and a specification of its sequential
-- consumption, produces Peek, which results in Just the successfully
-- taken value, or Nothing, if the specified length of data wasn't
-- enough.
parse :: Int -> Parse a -> (Int -> a) -> (Text -> a) -> Peek a
-- | Given the length of the data and a specification of its sequential
-- consumption, produces Peek, which results in Just the successfully
-- taken value, or Nothing, if the specified length of data wasn't
-- enough.
parseUnbound :: Int -> ParseUnbound a -> (Int -> a) -> (Text -> a) -> Peek a
-- | A standard idiom, where a header specifies the length of the body.
--
-- Produces Peek, which itself produces another Peek, which is the same
-- as the result of the parse function.
peekAmountAndParse :: Peek Int -> Parse a -> (Int -> a) -> (Text -> a) -> Peek (Peek a)
instance GHC.Base.Functor Ptr.Peek.Peek
instance GHC.Base.Applicative Ptr.Peek.Peek
module Ptr.Receive
-- | A wrapper of a receiving action, which extends it with bufferization.
data Receive
create :: (Ptr Word8 -> Int -> IO (Either Text Int)) -> Int -> IO Receive
-- | Receive as many bytes as is required by the provided decoder and
-- decode immediately.
--
-- If all you need is just to get a ByteString chunk then use the
-- bytes decoder.
peek :: Receive -> Peek peekd -> IO (Either Text peekd)
module Ptr.ByteString
poking :: Poking -> ByteString
parse :: ByteString -> Parse result -> (Int -> result) -> (Text -> result) -> result
peek :: ByteString -> Peek result -> Maybe result