| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Data.Persist
Synopsis
- class Persist t where
- type HostEndian = LittleEndian
- newtype BigEndian a = BigEndian {
- unBE :: a
- newtype LittleEndian a = LittleEndian {
- unLE :: a
- encode :: Persist a => a -> ByteString
- decode :: Persist a => ByteString -> Either String a
- data Get a
- runGet :: Get a -> ByteString -> Either String a
- ensure :: Int -> Get ()
- skip :: Int -> Get ()
- getBytes :: Int -> Get ByteString
- getByteString :: Int -> Get ByteString
- remaining :: Get Int
- eof :: Get ()
- getHE :: Persist (HostEndian a) => Get a
- getLE :: Persist (LittleEndian a) => Get a
- getBE :: Persist (BigEndian a) => Get a
- data Put a
- runPut :: Put a -> ByteString
- evalPut :: Put a -> (a, ByteString)
- grow :: Int -> Put ()
- putByteString :: ByteString -> Put ()
- putHE :: Persist (HostEndian a) => a -> Put ()
- putLE :: Persist (LittleEndian a) => a -> Put ()
- putBE :: Persist (BigEndian a) => a -> Put ()
The Persist class
Minimal complete definition
Nothing
Methods
Encode a value in the Put monad.
Decode a value in the Get monad
put :: (Generic t, GPersistPut (Rep t)) => t -> Put () #
Encode a value in the Put monad.
get :: (Generic t, GPersistGet (Rep t)) => Get t #
Decode a value in the Get monad
Instances
Endianness
type HostEndian = LittleEndian #
Instances
newtype LittleEndian a #
Constructors
| LittleEndian | |
Fields
| |
Instances
Serialization
encode :: Persist a => a -> ByteString #
Encode a value using binary serialization to a strict ByteString.
decode :: Persist a => ByteString -> Either String a #
Decode a value from a strict ByteString, reconstructing the original structure.
The Get type
runGet :: Get a -> ByteString -> Either String a #
Run the Get monad applies a get-based parser on the input ByteString
Ensure that n bytes are available. Fails if fewer than n bytes are available.
getBytes :: Int -> Get ByteString #
Pull n bytes from the input, as a strict ByteString.
getByteString :: Int -> Get ByteString #
An efficient get method for strict ByteStrings. Fails if fewer
than n bytes are left in the input. This function creates a fresh
copy of the underlying bytes.
Get the number of remaining unparsed bytes. Useful for checking whether all input has been consumed.
getHE :: Persist (HostEndian a) => Get a #
getLE :: Persist (LittleEndian a) => Get a #
The Put type
runPut :: Put a -> ByteString #
evalPut :: Put a -> (a, ByteString) #
putByteString :: ByteString -> Put () #
putHE :: Persist (HostEndian a) => a -> Put () #
putLE :: Persist (LittleEndian a) => a -> Put () #