ghc-binary-0.5.0.2: Binary serialisation for Haskell values using lazy ByteStringsSource codeContentsIndex
Data.Binary.Put
PortabilityPortable to Hugs and GHC. Requires MPTCs
Stabilitystable
MaintainerLennart Kolmodin <kolmodin@dtek.chalmers.se>
Contents
The Put type
Flushing the implicit parse state
Primitives
Big-endian primitives
Little-endian primitives
Host-endian, unaligned writes
Description
The Put monad. A monad for efficiently constructing lazy bytestrings.
Synopsis
type Put = PutM ()
newtype PutM a = Put {
unPut :: PairS a
}
runPut :: Put -> ByteString
runPutM :: PutM a -> (a, ByteString)
putBuilder :: Builder -> Put
execPut :: PutM a -> Builder
flush :: Put
putWord8 :: Word8 -> Put
putByteString :: ByteString -> Put
putLazyByteString :: ByteString -> Put
putWord16be :: Word16 -> Put
putWord32be :: Word32 -> Put
putWord64be :: Word64 -> Put
putWord16le :: Word16 -> Put
putWord32le :: Word32 -> Put
putWord64le :: Word64 -> Put
putWordhost :: Word -> Put
putWord16host :: Word16 -> Put
putWord32host :: Word32 -> Put
putWord64host :: Word64 -> Put
The Put type
type Put = PutM ()Source
Put merely lifts Builder into a Writer monad, applied to ().
newtype PutM a Source
The PutM type. A Writer monad over the efficient Builder monoid.
Constructors
Put
unPut :: PairS a
show/hide Instances
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
putBuilder :: Builder -> PutSource
execPut :: PutM a -> BuilderSource
Run the Put monad
Flushing the implicit parse state
flush :: PutSource
Pop the ByteString we have constructed so far, if any, yielding a new chunk in the result ByteString.
Primitives
putWord8 :: Word8 -> PutSource
Efficiently write a byte into the output buffer
putByteString :: ByteString -> PutSource
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 :: ByteString -> PutSource
Write a lazy ByteString efficiently, simply appending the lazy ByteString chunks to the output buffer
Big-endian primitives
putWord16be :: Word16 -> PutSource
Write a Word16 in big endian format
putWord32be :: Word32 -> PutSource
Write a Word32 in big endian format
putWord64be :: Word64 -> PutSource
Write a Word64 in big endian format
Little-endian primitives
putWord16le :: Word16 -> PutSource
Write a Word16 in little endian format
putWord32le :: Word32 -> PutSource
Write a Word32 in little endian format
putWord64le :: Word64 -> PutSource
Write a Word64 in little endian format
Host-endian, unaligned writes
putWordhost :: Word -> PutSource
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 :: Word16 -> PutSource
O(1). Write a Word16 in native host order and host endianness. For portability issues see putWordhost.
putWord32host :: Word32 -> PutSource
O(1). Write a Word32 in native host order and host endianness. For portability issues see putWordhost.
putWord64host :: Word64 -> PutSource
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.
Produced by Haddock version 2.6.1