-- 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.15.3 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 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.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 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 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 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, the specified length of data wasn't enough. parse :: Int -> Parse 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.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 beWord16 :: Poke Word16 beWord32 :: Poke Word32 beWord64 :: Poke Word64 bytes :: Int -> Poke ByteString pokeAndPeek :: PokeAndPeek input output -> Poke input instance Data.Functor.Contravariant.Contravariant Ptr.Poke.Poke instance Data.Functor.Contravariant.Divisible.Divisible Ptr.Poke.Poke module Ptr.Poking -- | Efficiently composable specification of how to populate a pointer. data Poking -- | Poking :: !Int -> !(Ptr Word8 -> IO ()) -> Poking -- | Same as mappend and <>, but performs the -- serialization concurrently. This comes at the cost of an overhead, so -- it is only advised to use this function when the merged serializations -- are heavy. prependConc :: Poking -> Poking -> Poking word8 :: Word8 -> Poking beWord32 :: Word32 -> Poking beWord64 :: Word64 -> Poking bytes :: ByteString -> Poking poke :: Poke input -> input -> Poking pokeAndPeek :: PokeAndPeek input output -> input -> Poking instance Data.Semigroup.Semigroup Ptr.Poking.Poking instance GHC.Base.Monoid Ptr.Poking.Poking module Ptr.ByteString poking :: Poking -> ByteString parse :: ByteString -> Parse result -> (Int -> result) -> (Text -> result) -> result peek :: ByteString -> Peek result -> Maybe result