persist-0.1.1.5: Minimal serialization library with focus on performance

Safe HaskellNone
LanguageHaskell2010

Data.Persist

Contents

Synopsis

The Persist class

class Persist t where Source #

Minimal complete definition

Nothing

Methods

put :: t -> Put () Source #

Encode a value in the Put monad.

get :: Get t Source #

Decode a value in the Get monad

put :: (Generic t, GPersistPut (Rep t)) => t -> Put () Source #

Encode a value in the Put monad.

get :: (Generic t, GPersistGet (Rep t)) => Get t Source #

Decode a value in the Get monad

Instances
Persist Bool Source # 
Instance details

Defined in Data.Persist

Methods

put :: Bool -> Put () Source #

get :: Get Bool Source #

Persist Char Source # 
Instance details

Defined in Data.Persist

Methods

put :: Char -> Put () Source #

get :: Get Char Source #

Persist Double Source # 
Instance details

Defined in Data.Persist

Methods

put :: Double -> Put () Source #

get :: Get Double Source #

Persist Float Source # 
Instance details

Defined in Data.Persist

Methods

put :: Float -> Put () Source #

get :: Get Float Source #

Persist Int Source # 
Instance details

Defined in Data.Persist

Methods

put :: Int -> Put () Source #

get :: Get Int Source #

Persist Int8 Source # 
Instance details

Defined in Data.Persist

Methods

put :: Int8 -> Put () Source #

get :: Get Int8 Source #

Persist Int16 Source # 
Instance details

Defined in Data.Persist

Methods

put :: Int16 -> Put () Source #

get :: Get Int16 Source #

Persist Int32 Source # 
Instance details

Defined in Data.Persist

Methods

put :: Int32 -> Put () Source #

get :: Get Int32 Source #

Persist Int64 Source # 
Instance details

Defined in Data.Persist

Methods

put :: Int64 -> Put () Source #

get :: Get Int64 Source #

Persist Integer Source # 
Instance details

Defined in Data.Persist

Methods

put :: Integer -> Put () Source #

get :: Get Integer Source #

Persist Natural Source # 
Instance details

Defined in Data.Persist

Methods

put :: Natural -> Put () Source #

get :: Get Natural Source #

Persist Ordering Source # 
Instance details

Defined in Data.Persist

Persist Word Source # 
Instance details

Defined in Data.Persist

Methods

put :: Word -> Put () Source #

get :: Get Word Source #

Persist Word8 Source # 
Instance details

Defined in Data.Persist

Methods

put :: Word8 -> Put () Source #

get :: Get Word8 Source #

Persist Word16 Source # 
Instance details

Defined in Data.Persist

Methods

put :: Word16 -> Put () Source #

get :: Get Word16 Source #

Persist Word32 Source # 
Instance details

Defined in Data.Persist

Methods

put :: Word32 -> Put () Source #

get :: Get Word32 Source #

Persist Word64 Source # 
Instance details

Defined in Data.Persist

Methods

put :: Word64 -> Put () Source #

get :: Get Word64 Source #

Persist () Source # 
Instance details

Defined in Data.Persist

Methods

put :: () -> Put () Source #

get :: Get () Source #

Persist All Source # 
Instance details

Defined in Data.Persist

Methods

put :: All -> Put () Source #

get :: Get All Source #

Persist Any Source # 
Instance details

Defined in Data.Persist

Methods

put :: Any -> Put () Source #

get :: Get Any Source #

Persist ShortByteString Source # 
Instance details

Defined in Data.Persist

Persist ByteString Source # 
Instance details

Defined in Data.Persist

Persist ByteString Source # 
Instance details

Defined in Data.Persist

Persist IntSet Source # 
Instance details

Defined in Data.Persist

Methods

put :: IntSet -> Put () Source #

get :: Get IntSet Source #

Persist Text Source # 
Instance details

Defined in Data.Persist

Methods

put :: Text -> Put () Source #

get :: Get Text Source #

Persist a => Persist [a] Source #

Persist a list in the following format: Word64 (little endian format) element 1 ... element n

Instance details

Defined in Data.Persist

Methods

put :: [a] -> Put () Source #

get :: Get [a] Source #

Persist a => Persist (Maybe a) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Maybe a -> Put () Source #

get :: Get (Maybe a) Source #

Persist a => Persist (Ratio a) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Ratio a -> Put () Source #

get :: Get (Ratio a) Source #

Persist a => Persist (First a) Source # 
Instance details

Defined in Data.Persist

Methods

put :: First a -> Put () Source #

get :: Get (First a) Source #

Persist a => Persist (Last a) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Last a -> Put () Source #

get :: Get (Last a) Source #

Persist a => Persist (Dual a) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Dual a -> Put () Source #

get :: Get (Dual a) Source #

Persist a => Persist (Sum a) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Sum a -> Put () Source #

get :: Get (Sum a) Source #

Persist a => Persist (Product a) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Product a -> Put () Source #

get :: Get (Product a) Source #

Persist e => Persist (NonEmpty e) Source # 
Instance details

Defined in Data.Persist

Methods

put :: NonEmpty e -> Put () Source #

get :: Get (NonEmpty e) Source #

Persist e => Persist (IntMap e) Source # 
Instance details

Defined in Data.Persist

Methods

put :: IntMap e -> Put () Source #

get :: Get (IntMap e) Source #

Persist e => Persist (Tree e) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Tree e -> Put () Source #

get :: Get (Tree e) Source #

Persist e => Persist (Seq e) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Seq e -> Put () Source #

get :: Get (Seq e) Source #

(Ord a, Persist a) => Persist (Set a) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Set a -> Put () Source #

get :: Get (Set a) Source #

Persist (LittleEndian Double) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Float) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Int) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Int16) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Int32) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Int64) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Word) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Word16) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Word32) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Word64) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Double) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Float) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Int) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Int16) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Int32) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Int64) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Word) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Word16) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Word32) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Word64) Source # 
Instance details

Defined in Data.Persist

(Persist a, Persist b) => Persist (Either a b) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Either a b -> Put () Source #

get :: Get (Either a b) Source #

(Persist a, Persist b) => Persist (a, b) Source # 
Instance details

Defined in Data.Persist

Methods

put :: (a, b) -> Put () Source #

get :: Get (a, b) Source #

(Ord k, Persist k, Persist e) => Persist (Map k e) Source # 
Instance details

Defined in Data.Persist

Methods

put :: Map k e -> Put () Source #

get :: Get (Map k e) Source #

(Persist a, Persist b, Persist c) => Persist (a, b, c) Source # 
Instance details

Defined in Data.Persist

Methods

put :: (a, b, c) -> Put () Source #

get :: Get (a, b, c) Source #

(Persist a, Persist b, Persist c, Persist d) => Persist (a, b, c, d) Source # 
Instance details

Defined in Data.Persist

Methods

put :: (a, b, c, d) -> Put () Source #

get :: Get (a, b, c, d) Source #

(Persist a, Persist b, Persist c, Persist d, Persist e) => Persist (a, b, c, d, e) Source # 
Instance details

Defined in Data.Persist

Methods

put :: (a, b, c, d, e) -> Put () Source #

get :: Get (a, b, c, d, e) Source #

(Persist a, Persist b, Persist c, Persist d, Persist e, Persist f) => Persist (a, b, c, d, e, f) Source # 
Instance details

Defined in Data.Persist

Methods

put :: (a, b, c, d, e, f) -> Put () Source #

get :: Get (a, b, c, d, e, f) Source #

(Persist a, Persist b, Persist c, Persist d, Persist e, Persist f, Persist g) => Persist (a, b, c, d, e, f, g) Source # 
Instance details

Defined in Data.Persist

Methods

put :: (a, b, c, d, e, f, g) -> Put () Source #

get :: Get (a, b, c, d, e, f, g) Source #

Endianness

newtype BigEndian a Source #

Constructors

BigEndian 

Fields

Instances
Functor BigEndian Source # 
Instance details

Defined in Data.Persist

Methods

fmap :: (a -> b) -> BigEndian a -> BigEndian b #

(<$) :: a -> BigEndian b -> BigEndian a #

Foldable BigEndian Source # 
Instance details

Defined in Data.Persist

Methods

fold :: Monoid m => BigEndian m -> m #

foldMap :: Monoid m => (a -> m) -> BigEndian a -> m #

foldr :: (a -> b -> b) -> b -> BigEndian a -> b #

foldr' :: (a -> b -> b) -> b -> BigEndian a -> b #

foldl :: (b -> a -> b) -> b -> BigEndian a -> b #

foldl' :: (b -> a -> b) -> b -> BigEndian a -> b #

foldr1 :: (a -> a -> a) -> BigEndian a -> a #

foldl1 :: (a -> a -> a) -> BigEndian a -> a #

toList :: BigEndian a -> [a] #

null :: BigEndian a -> Bool #

length :: BigEndian a -> Int #

elem :: Eq a => a -> BigEndian a -> Bool #

maximum :: Ord a => BigEndian a -> a #

minimum :: Ord a => BigEndian a -> a #

sum :: Num a => BigEndian a -> a #

product :: Num a => BigEndian a -> a #

Traversable BigEndian Source # 
Instance details

Defined in Data.Persist

Methods

traverse :: Applicative f => (a -> f b) -> BigEndian a -> f (BigEndian b) #

sequenceA :: Applicative f => BigEndian (f a) -> f (BigEndian a) #

mapM :: Monad m => (a -> m b) -> BigEndian a -> m (BigEndian b) #

sequence :: Monad m => BigEndian (m a) -> m (BigEndian a) #

Eq a => Eq (BigEndian a) Source # 
Instance details

Defined in Data.Persist

Methods

(==) :: BigEndian a -> BigEndian a -> Bool #

(/=) :: BigEndian a -> BigEndian a -> Bool #

Ord a => Ord (BigEndian a) Source # 
Instance details

Defined in Data.Persist

Show a => Show (BigEndian a) Source # 
Instance details

Defined in Data.Persist

Generic (BigEndian a) Source # 
Instance details

Defined in Data.Persist

Associated Types

type Rep (BigEndian a) :: Type -> Type #

Methods

from :: BigEndian a -> Rep (BigEndian a) x #

to :: Rep (BigEndian a) x -> BigEndian a #

Persist (BigEndian Double) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Float) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Int) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Int16) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Int32) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Int64) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Word) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Word16) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Word32) Source # 
Instance details

Defined in Data.Persist

Persist (BigEndian Word64) Source # 
Instance details

Defined in Data.Persist

type Rep (BigEndian a) Source # 
Instance details

Defined in Data.Persist

type Rep (BigEndian a) = D1 (MetaData "BigEndian" "Data.Persist" "persist-0.1.1.5-3fRfER2dz4nmyd45Qi4cs" True) (C1 (MetaCons "BigEndian" PrefixI True) (S1 (MetaSel (Just "unBE") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

newtype LittleEndian a Source #

Constructors

LittleEndian 

Fields

Instances
Functor LittleEndian Source # 
Instance details

Defined in Data.Persist

Methods

fmap :: (a -> b) -> LittleEndian a -> LittleEndian b #

(<$) :: a -> LittleEndian b -> LittleEndian a #

Foldable LittleEndian Source # 
Instance details

Defined in Data.Persist

Methods

fold :: Monoid m => LittleEndian m -> m #

foldMap :: Monoid m => (a -> m) -> LittleEndian a -> m #

foldr :: (a -> b -> b) -> b -> LittleEndian a -> b #

foldr' :: (a -> b -> b) -> b -> LittleEndian a -> b #

foldl :: (b -> a -> b) -> b -> LittleEndian a -> b #

foldl' :: (b -> a -> b) -> b -> LittleEndian a -> b #

foldr1 :: (a -> a -> a) -> LittleEndian a -> a #

foldl1 :: (a -> a -> a) -> LittleEndian a -> a #

toList :: LittleEndian a -> [a] #

null :: LittleEndian a -> Bool #

length :: LittleEndian a -> Int #

elem :: Eq a => a -> LittleEndian a -> Bool #

maximum :: Ord a => LittleEndian a -> a #

minimum :: Ord a => LittleEndian a -> a #

sum :: Num a => LittleEndian a -> a #

product :: Num a => LittleEndian a -> a #

Traversable LittleEndian Source # 
Instance details

Defined in Data.Persist

Methods

traverse :: Applicative f => (a -> f b) -> LittleEndian a -> f (LittleEndian b) #

sequenceA :: Applicative f => LittleEndian (f a) -> f (LittleEndian a) #

mapM :: Monad m => (a -> m b) -> LittleEndian a -> m (LittleEndian b) #

sequence :: Monad m => LittleEndian (m a) -> m (LittleEndian a) #

Eq a => Eq (LittleEndian a) Source # 
Instance details

Defined in Data.Persist

Ord a => Ord (LittleEndian a) Source # 
Instance details

Defined in Data.Persist

Show a => Show (LittleEndian a) Source # 
Instance details

Defined in Data.Persist

Generic (LittleEndian a) Source # 
Instance details

Defined in Data.Persist

Associated Types

type Rep (LittleEndian a) :: Type -> Type #

Methods

from :: LittleEndian a -> Rep (LittleEndian a) x #

to :: Rep (LittleEndian a) x -> LittleEndian a #

Persist (LittleEndian Double) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Float) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Int) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Int16) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Int32) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Int64) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Word) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Word16) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Word32) Source # 
Instance details

Defined in Data.Persist

Persist (LittleEndian Word64) Source # 
Instance details

Defined in Data.Persist

type Rep (LittleEndian a) Source # 
Instance details

Defined in Data.Persist

type Rep (LittleEndian a) = D1 (MetaData "LittleEndian" "Data.Persist" "persist-0.1.1.5-3fRfER2dz4nmyd45Qi4cs" True) (C1 (MetaCons "LittleEndian" PrefixI True) (S1 (MetaSel (Just "unLE") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))

Serialization

encode :: Persist a => a -> ByteString Source #

Encode a value using binary serialization to a strict ByteString.

decode :: Persist a => ByteString -> Either String a Source #

Decode a value from a strict ByteString, reconstructing the original structure.

The Get type

data Get a Source #

Instances
Monad Get Source # 
Instance details

Defined in Data.Persist.Internal

Methods

(>>=) :: Get a -> (a -> Get b) -> Get b #

(>>) :: Get a -> Get b -> Get b #

return :: a -> Get a #

fail :: String -> Get a #

Functor Get Source # 
Instance details

Defined in Data.Persist.Internal

Methods

fmap :: (a -> b) -> Get a -> Get b #

(<$) :: a -> Get b -> Get a #

MonadFail Get Source # 
Instance details

Defined in Data.Persist.Internal

Methods

fail :: String -> Get a #

Applicative Get Source # 
Instance details

Defined in Data.Persist.Internal

Methods

pure :: a -> Get a #

(<*>) :: Get (a -> b) -> Get a -> Get b #

liftA2 :: (a -> b -> c) -> Get a -> Get b -> Get c #

(*>) :: Get a -> Get b -> Get b #

(<*) :: Get a -> Get b -> Get a #

runGet :: Get a -> ByteString -> Either String a Source #

Run the Get monad applies a get-based parser on the input ByteString

ensure :: Int -> Get () Source #

Ensure that n bytes are available. Fails if fewer than n bytes are available.

skip :: Int -> Get () Source #

Skip ahead n bytes. Fails if fewer than n bytes are available.

getBytes :: Int -> Get ByteString Source #

Pull n bytes from the input, as a strict ByteString.

getByteString :: Int -> Get ByteString Source #

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.

remaining :: Get Int Source #

Get the number of remaining unparsed bytes. Useful for checking whether all input has been consumed.

eof :: Get () Source #

The Put type

data Put a Source #

Instances
Monad Put Source # 
Instance details

Defined in Data.Persist.Internal

Methods

(>>=) :: Put a -> (a -> Put b) -> Put b #

(>>) :: Put a -> Put b -> Put b #

return :: a -> Put a #

fail :: String -> Put a #

Functor Put Source # 
Instance details

Defined in Data.Persist.Internal

Methods

fmap :: (a -> b) -> Put a -> Put b #

(<$) :: a -> Put b -> Put a #

Applicative Put Source # 
Instance details

Defined in Data.Persist.Internal

Methods

pure :: a -> Put a #

(<*>) :: Put (a -> b) -> Put a -> Put b #

liftA2 :: (a -> b -> c) -> Put a -> Put b -> Put c #

(*>) :: Put a -> Put b -> Put b #

(<*) :: Put a -> Put b -> Put a #

grow :: Int -> Put () Source #

Ensure that n bytes can be written.

putHE :: Persist (HostEndian a) => a -> Put () Source #

putLE :: Persist (LittleEndian a) => a -> Put () Source #

putBE :: Persist (BigEndian a) => a -> Put () Source #