Stability | Portability : |
---|---|
Maintainer | Trevor Elliott <trevor@galois.com> |
Safe Haskell | Safe-Infered |
The Put monad. A monad for efficiently constructing bytestrings.
- type Put = PutM ()
- newtype PutM a = Put {
- unPut :: PairS a
- type Putter a = a -> Put
- runPut :: Put -> ByteString
- runPutM :: PutM a -> (a, ByteString)
- runPutLazy :: Put -> ByteString
- runPutMLazy :: PutM a -> (a, ByteString)
- putBuilder :: Putter Builder
- execPut :: PutM a -> Builder
- flush :: Put
- putWord8 :: Putter Word8
- putByteString :: Putter ByteString
- putLazyByteString :: Putter ByteString
- putWord16be :: Putter Word16
- putWord32be :: Putter Word32
- putWord64be :: Putter Word64
- putWord16le :: Putter Word16
- putWord32le :: Putter Word32
- putWord64le :: Putter Word64
- putWordhost :: Putter Word
- putWord16host :: Putter Word16
- putWord32host :: Putter Word32
- putWord64host :: Putter Word64
- putTwoOf :: Putter a -> Putter b -> Putter (a, b)
- putListOf :: Putter a -> Putter [a]
- putIArrayOf :: (Ix i, IArray a e) => Putter i -> Putter e -> Putter (a i e)
- putSeqOf :: Putter a -> Putter (Seq a)
- putTreeOf :: Putter a -> Putter (Tree a)
- putMapOf :: Ord k => Putter k -> Putter a -> Putter (Map k a)
- putIntMapOf :: Putter Int -> Putter a -> Putter (IntMap a)
- putSetOf :: Putter a -> Putter (Set a)
- putIntSetOf :: Putter Int -> Putter IntSet
- putMaybeOf :: Putter a -> Putter (Maybe a)
- putEitherOf :: Putter a -> Putter b -> Putter (Either a b)
The Put type
The PutM type. A Writer monad over the efficient Builder monoid.
runPut :: Put -> ByteStringSource
Run the Put
monad with a serialiser
runPutM :: PutM a -> (a, ByteString)Source
Run the Put
monad with a serialiser and get its result
runPutLazy :: Put -> ByteStringSource
Run the Put
monad with a serialiser
runPutMLazy :: PutM a -> (a, ByteString)Source
Run the Put
monad with a serialiser
Flushing the implicit parse state
Pop the ByteString we have constructed so far, if any, yielding a new chunk in the result ByteString.
Primitives
putByteString :: Putter ByteStringSource
An efficient primitive to write a strict ByteString into the output buffer. It flushes the current buffer, and writes the argument into a new chunk.
putLazyByteString :: Putter ByteStringSource
Write a lazy ByteString efficiently, simply appending the lazy ByteString chunks to the output buffer
Big-endian primitives
putWord16be :: Putter Word16Source
Write a Word16 in big endian format
putWord32be :: Putter Word32Source
Write a Word32 in big endian format
putWord64be :: Putter Word64Source
Write a Word64 in big endian format
Little-endian primitives
putWord16le :: Putter Word16Source
Write a Word16 in little endian format
putWord32le :: Putter Word32Source
Write a Word32 in little endian format
putWord64le :: Putter Word64Source
Write a Word64 in little endian format
Host-endian, unaligned writes
putWordhost :: Putter WordSource
O(1). Write a single native machine word. The word is written in host order, host endian form, for the machine you're on. On a 64 bit machine the Word is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this way are not portable to different endian or word sized machines, without conversion.
putWord16host :: Putter Word16Source
O(1). Write a Word16 in native host order and host endianness.
For portability issues see putWordhost
.
putWord32host :: Putter Word32Source
O(1). Write a Word32 in native host order and host endianness.
For portability issues see putWordhost
.
putWord64host :: Putter Word64Source
O(1). Write a Word64 in native host order
On a 32 bit machine we write two host order Word32s, in big endian form.
For portability issues see putWordhost
.
Containers
putMaybeOf :: Putter a -> Putter (Maybe a)Source