store-0.7.16: Fast binary serialization
Safe HaskellNone
LanguageHaskell2010

Data.Store

Description

This is the main public API of the store package. The functions exported here are more likely to be stable between versions.

Usually you won't need to write your own Store instances, and instead can rely on either using the Generic deriving approach or Data.Store.TH for defining Store instances for your datatypes. There are some tradeoffs here - the generics instances do not require -XTemplateHaskell, but they do not optimize as well for sum types that only require a constant number of bytes.

If you need streaming encode / decode of multiple store encoded messages, take a look at the store-streaming package.

Gotchas

Store is best used for communication between trusted processes and local caches. It can certainly be used for other purposes, but the builtin set of instances have some gotchas to be aware of:

  • Store's builtin instances serialize in a format which depends on machine endianness.
  • Store's builtin instances trust the data when deserializing. For example, the deserialization of Vector will read the vector's link from the first 8 bytes. It will then allocate enough memory to store all the elements. Malicious or malformed input could cause allocation of large amounts of memory. See https://github.com/fpco/store/issues/122
Synopsis

Encoding and decoding strict ByteStrings.

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

Serializes a value to a ByteString. In order to do this, it first allocates a ByteString of the correct size (based on size), and then uses poke to fill it.

Safety of this function depends on correctness of the Store instance. If size returns a. The good news is that this isn't an issue if you use well-tested manual instances (such as those from this package) combined with auomatic definition of instances.

decode :: Store a => ByteString -> Either PeekException a Source #

Decodes a value from a ByteString. Returns an exception if there's an error while decoding, or if decoding undershoots / overshoots the end of the buffer.

decodeWith :: Peek a -> ByteString -> Either PeekException a #

Decodes a value from a ByteString, potentially throwing exceptions, and taking a Peek to run. It is an exception to not consume all input.

decodeEx :: Store a => ByteString -> a Source #

Decodes a value from a ByteString, potentially throwing exceptions. It is an exception to not consume all input.

decodeExWith :: Peek a -> ByteString -> a #

Decodes a value from a ByteString, potentially throwing exceptions, and taking a Peek to run. It is an exception to not consume all input.

decodeExPortionWith :: Peek a -> ByteString -> (Offset, a) #

Similar to decodeExWith, but it allows there to be more of the buffer remaining. The Offset of the buffer contents immediately after the decoded value is returned.

decodeIO :: Store a => ByteString -> IO a Source #

Decodes a value from a ByteString, potentially throwing exceptions. It is an exception to not consume all input.

decodeIOWith :: Peek a -> ByteString -> IO a #

Decodes a value from a ByteString, potentially throwing exceptions, and taking a Peek to run. It is an exception to not consume all input.

decodeIOPortionWith :: Peek a -> ByteString -> IO (Offset, a) #

Similar to decodeExPortionWith, but runs in the IO monad.

Store class and related types.

class Store a where Source #

The Store typeclass provides efficient serialization and deserialization to raw pointer addresses.

The peek and poke methods should be defined such that decodeEx (encode x) == x .

Minimal complete definition

Nothing

Methods

size :: Size a Source #

Yields the Size of the buffer, in bytes, required to store the encoded representation of the type.

Note that the correctness of this function is crucial for the safety of poke, as it does not do any bounds checking. It is the responsibility of the invoker of poke (encode and similar functions) to ensure that there's enough space in the output buffer. If poke writes beyond, then arbitrary memory can be overwritten, causing undefined behavior and segmentation faults.

default size :: (Generic a, GStoreSize (Rep a)) => Size a Source #

poke :: a -> Poke () Source #

Serializes a value to bytes. It is the responsibility of the caller to ensure that at least the number of bytes required by size are available. These details are handled by encode and similar utilities.

default poke :: (Generic a, GStorePoke (Rep a)) => a -> Poke () Source #

peek :: Peek a Source #

Serialized a value from bytes, throwing exceptions if it encounters invalid data or runs out of input bytes.

default peek :: (Generic a, GStorePeek (Rep a)) => Peek a Source #

Instances

Instances details
Store Bool Source # 
Instance details

Defined in Data.Store.Internal

Store Char Source # 
Instance details

Defined in Data.Store.Internal

Store Double Source # 
Instance details

Defined in Data.Store.Internal

Store Float Source # 
Instance details

Defined in Data.Store.Internal

Store Int Source # 
Instance details

Defined in Data.Store.Internal

Store Int8 Source # 
Instance details

Defined in Data.Store.Internal

Store Int16 Source # 
Instance details

Defined in Data.Store.Internal

Store Int32 Source # 
Instance details

Defined in Data.Store.Internal

Store Int64 Source # 
Instance details

Defined in Data.Store.Internal

Store Integer Source # 
Instance details

Defined in Data.Store.Internal

Store Natural Source # 
Instance details

Defined in Data.Store.Internal

Store Word Source # 
Instance details

Defined in Data.Store.Internal

Store Word8 Source # 
Instance details

Defined in Data.Store.Internal

Store Word16 Source # 
Instance details

Defined in Data.Store.Internal

Store Word32 Source # 
Instance details

Defined in Data.Store.Internal

Store Word64 Source # 
Instance details

Defined in Data.Store.Internal

Store Exp Source # 
Instance details

Defined in Data.Store.Internal

Store Match Source # 
Instance details

Defined in Data.Store.Internal

Store Clause Source # 
Instance details

Defined in Data.Store.Internal

Store Pat Source # 
Instance details

Defined in Data.Store.Internal

Store Type Source # 
Instance details

Defined in Data.Store.Internal

Store Dec Source # 
Instance details

Defined in Data.Store.Internal

Store Name Source # 
Instance details

Defined in Data.Store.Internal

Store FunDep Source # 
Instance details

Defined in Data.Store.Internal

Store InjectivityAnn Source # 
Instance details

Defined in Data.Store.Internal

Store Overlap Source # 
Instance details

Defined in Data.Store.Internal

Store () Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size () Source #

poke :: () -> Poke () Source #

peek :: Peek () Source #

Store Void Source # 
Instance details

Defined in Data.Store.Internal

Store CDev Source # 
Instance details

Defined in Data.Store.Internal

Store CIno Source # 
Instance details

Defined in Data.Store.Internal

Store CMode Source # 
Instance details

Defined in Data.Store.Internal

Store COff Source # 
Instance details

Defined in Data.Store.Internal

Store CPid Source # 
Instance details

Defined in Data.Store.Internal

Store CSsize Source # 
Instance details

Defined in Data.Store.Internal

Store CGid Source # 
Instance details

Defined in Data.Store.Internal

Store CNlink Source # 
Instance details

Defined in Data.Store.Internal

Store CUid Source # 
Instance details

Defined in Data.Store.Internal

Store CCc Source # 
Instance details

Defined in Data.Store.Internal

Store CSpeed Source # 
Instance details

Defined in Data.Store.Internal

Store CTcflag Source # 
Instance details

Defined in Data.Store.Internal

Store CRLim Source # 
Instance details

Defined in Data.Store.Internal

Store CBlkSize Source # 
Instance details

Defined in Data.Store.Internal

Store CBlkCnt Source # 
Instance details

Defined in Data.Store.Internal

Store CClockId Source # 
Instance details

Defined in Data.Store.Internal

Store CFsBlkCnt Source # 
Instance details

Defined in Data.Store.Internal

Store CFsFilCnt Source # 
Instance details

Defined in Data.Store.Internal

Store CId Source # 
Instance details

Defined in Data.Store.Internal

Store CKey Source # 
Instance details

Defined in Data.Store.Internal

Store CTimer Source # 
Instance details

Defined in Data.Store.Internal

Store CSocklen Source # 
Instance details

Defined in Data.Store.Internal

Store CNfds Source # 
Instance details

Defined in Data.Store.Internal

Store Fd Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size Fd Source #

poke :: Fd -> Poke () Source #

peek :: Peek Fd Source #

Store All Source # 
Instance details

Defined in Data.Store.Internal

Store Any Source # 
Instance details

Defined in Data.Store.Internal

Store CChar Source # 
Instance details

Defined in Data.Store.Internal

Store CSChar Source # 
Instance details

Defined in Data.Store.Internal

Store CUChar Source # 
Instance details

Defined in Data.Store.Internal

Store CShort Source # 
Instance details

Defined in Data.Store.Internal

Store CUShort Source # 
Instance details

Defined in Data.Store.Internal

Store CInt Source # 
Instance details

Defined in Data.Store.Internal

Store CUInt Source # 
Instance details

Defined in Data.Store.Internal

Store CLong Source # 
Instance details

Defined in Data.Store.Internal

Store CULong Source # 
Instance details

Defined in Data.Store.Internal

Store CLLong Source # 
Instance details

Defined in Data.Store.Internal

Store CULLong Source # 
Instance details

Defined in Data.Store.Internal

Store CBool Source # 
Instance details

Defined in Data.Store.Internal

Store CFloat Source # 
Instance details

Defined in Data.Store.Internal

Store CDouble Source # 
Instance details

Defined in Data.Store.Internal

Store CPtrdiff Source # 
Instance details

Defined in Data.Store.Internal

Store CSize Source # 
Instance details

Defined in Data.Store.Internal

Store CWchar Source # 
Instance details

Defined in Data.Store.Internal

Store CSigAtomic Source # 
Instance details

Defined in Data.Store.Internal

Store CClock Source # 
Instance details

Defined in Data.Store.Internal

Store CTime Source # 
Instance details

Defined in Data.Store.Internal

Store CUSeconds Source # 
Instance details

Defined in Data.Store.Internal

Store CSUSeconds Source # 
Instance details

Defined in Data.Store.Internal

Store CIntPtr Source # 
Instance details

Defined in Data.Store.Internal

Store CUIntPtr Source # 
Instance details

Defined in Data.Store.Internal

Store CIntMax Source # 
Instance details

Defined in Data.Store.Internal

Store CUIntMax Source # 
Instance details

Defined in Data.Store.Internal

Store WordPtr Source # 
Instance details

Defined in Data.Store.Internal

Store IntPtr Source # 
Instance details

Defined in Data.Store.Internal

Store Fingerprint Source # 
Instance details

Defined in Data.Store.Internal

Store ShortByteString Source # 
Instance details

Defined in Data.Store.Internal

Store ByteString Source # 
Instance details

Defined in Data.Store.Internal

Store ByteString Source # 
Instance details

Defined in Data.Store.Internal

Store TimeSpec Source # 
Instance details

Defined in Data.Store.Internal

Store IntSet Source # 
Instance details

Defined in Data.Store.Internal

Store PortNumber Source # 
Instance details

Defined in Data.Store.Internal

Store ModName Source # 
Instance details

Defined in Data.Store.Internal

Store PkgName Source # 
Instance details

Defined in Data.Store.Internal

Store OccName Source # 
Instance details

Defined in Data.Store.Internal

Store NameFlavour Source # 
Instance details

Defined in Data.Store.Internal

Store NameSpace Source # 
Instance details

Defined in Data.Store.Internal

Store Info Source # 
Instance details

Defined in Data.Store.Internal

Store Fixity Source # 
Instance details

Defined in Data.Store.Internal

Store FixityDirection Source # 
Instance details

Defined in Data.Store.Internal

Store Lit Source # 
Instance details

Defined in Data.Store.Internal

Store Bytes Source #

Template Haskell Bytes are nearly identical to ByteString, but it can't depend on ByteString.

Instance details

Defined in Data.Store.Internal

Store Body Source # 
Instance details

Defined in Data.Store.Internal

Store Guard Source # 
Instance details

Defined in Data.Store.Internal

Store Stmt Source # 
Instance details

Defined in Data.Store.Internal

Store Range Source # 
Instance details

Defined in Data.Store.Internal

Store DerivClause Source # 
Instance details

Defined in Data.Store.Internal

Store DerivStrategy Source # 
Instance details

Defined in Data.Store.Internal

Store TypeFamilyHead Source # 
Instance details

Defined in Data.Store.Internal

Store TySynEqn Source # 
Instance details

Defined in Data.Store.Internal

Store Foreign Source # 
Instance details

Defined in Data.Store.Internal

Store Callconv Source # 
Instance details

Defined in Data.Store.Internal

Store Safety Source # 
Instance details

Defined in Data.Store.Internal

Store Pragma Source # 
Instance details

Defined in Data.Store.Internal

Store Inline Source # 
Instance details

Defined in Data.Store.Internal

Store RuleMatch Source # 
Instance details

Defined in Data.Store.Internal

Store Phases Source # 
Instance details

Defined in Data.Store.Internal

Store RuleBndr Source # 
Instance details

Defined in Data.Store.Internal

Store AnnTarget Source # 
Instance details

Defined in Data.Store.Internal

Store SourceUnpackedness Source # 
Instance details

Defined in Data.Store.Internal

Store SourceStrictness Source # 
Instance details

Defined in Data.Store.Internal

Store Con Source # 
Instance details

Defined in Data.Store.Internal

Store Bang Source # 
Instance details

Defined in Data.Store.Internal

Store PatSynDir Source # 
Instance details

Defined in Data.Store.Internal

Store PatSynArgs Source # 
Instance details

Defined in Data.Store.Internal

Store TyVarBndr Source # 
Instance details

Defined in Data.Store.Internal

Store FamilyResultSig Source # 
Instance details

Defined in Data.Store.Internal

Store TyLit Source # 
Instance details

Defined in Data.Store.Internal

Store Role Source # 
Instance details

Defined in Data.Store.Internal

Store Text Source # 
Instance details

Defined in Data.Store.Internal

Store FormatExtension Source # 
Instance details

Defined in Data.Store.Internal

Store ZonedTime Source # 
Instance details

Defined in Data.Store.Internal

Store TimeLocale Source # 
Instance details

Defined in Data.Store.Internal

Store LocalTime Source # 
Instance details

Defined in Data.Store.Internal

Store TimeOfDay Source # 
Instance details

Defined in Data.Store.Internal

Store TimeZone Source # 
Instance details

Defined in Data.Store.Internal

Store CalendarDiffTime Source # 
Instance details

Defined in Data.Store.Internal

Store UniversalTime Source # 
Instance details

Defined in Data.Store.Internal

Store UTCTime Source # 
Instance details

Defined in Data.Store.Internal

Store SystemTime Source # 
Instance details

Defined in Data.Store.Internal

Store NominalDiffTime Source # 
Instance details

Defined in Data.Store.Internal

Store AbsoluteTime Source # 
Instance details

Defined in Data.Store.Internal

Store DiffTime Source # 
Instance details

Defined in Data.Store.Internal

Store Day Source # 
Instance details

Defined in Data.Store.Internal

Store CalendarDiffDays Source # 
Instance details

Defined in Data.Store.Internal

Store TypeHash Source # 
Instance details

Defined in Data.Store.TypeHash.Internal

Store StoreVersion Source # 
Instance details

Defined in Data.Store.Version

Deriver (Store a) Source # 
Instance details

Defined in Data.Store.TH.Internal

Methods

runDeriver :: Proxy (Store a) -> Cxt -> Type -> Q [Dec] #

Store a => Store [a] Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size [a] Source #

poke :: [a] -> Poke () Source #

peek :: Peek [a] Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Maybe a) Source #

poke :: Maybe a -> Poke () Source #

peek :: Peek (Maybe a) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Ratio a) Source #

poke :: Ratio a -> Poke () Source #

peek :: Peek (Ratio a) Source #

Store (StablePtr a) Source # 
Instance details

Defined in Data.Store.Internal

Store (Ptr a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Ptr a) Source #

poke :: Ptr a -> Poke () Source #

peek :: Peek (Ptr a) Source #

Store (FunPtr a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (FunPtr a) Source #

poke :: FunPtr a -> Poke () Source #

peek :: Peek (FunPtr a) Source #

Store a => Store (Complex a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Complex a) Source #

poke :: Complex a -> Poke () Source #

peek :: Peek (Complex a) Source #

Store a => Store (Identity a) Source # 
Instance details

Defined in Data.Store.Internal

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

Defined in Data.Store.Internal

Methods

size :: Size (First a) Source #

poke :: First a -> Poke () Source #

peek :: Peek (First a) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Last a) Source #

poke :: Last a -> Poke () Source #

peek :: Peek (Last a) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Dual a) Source #

poke :: Dual a -> Poke () Source #

peek :: Peek (Dual a) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Sum a) Source #

poke :: Sum a -> Poke () Source #

peek :: Peek (Sum a) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Product a) Source #

poke :: Product a -> Poke () Source #

peek :: Peek (Product a) Source #

Store a => Store (NonEmpty a) Source # 
Instance details

Defined in Data.Store.Internal

Store a => Store (IntMap a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (IntMap a) Source #

poke :: IntMap a -> Poke () Source #

peek :: Peek (IntMap a) Source #

Store a => Store (Seq a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Seq a) Source #

poke :: Seq a -> Poke () Source #

peek :: Peek (Seq a) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Set a) Source #

poke :: Set a -> Poke () Source #

peek :: Peek (Set a) Source #

Prim a => Store (PrimStorable a) Source # 
Instance details

Defined in Data.Store.Internal

(Eq a, Hashable a, Store a) => Store (HashSet a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (HashSet a) Source #

poke :: HashSet a -> Poke () Source #

peek :: Peek (HashSet a) Source #

Store (Vector Bool) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Char) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Double) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Float) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int8) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int16) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int32) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int64) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word8) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word16) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word32) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word64) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector ()) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector ()) Source #

poke :: Vector () -> Poke () Source #

peek :: Peek (Vector ()) Source #

(Store (Vector a), Store (Vector b)) => Store (Vector (a, b)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (a, b)) Source #

poke :: Vector (a, b) -> Poke () Source #

peek :: Peek (Vector (a, b)) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Vector (a, b, c)) Source #

poke :: Vector (a, b, c) -> Poke () Source #

peek :: Peek (Vector (a, b, c)) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Vector (a, b, c, d)) Source #

poke :: Vector (a, b, c, d) -> Poke () Source #

peek :: Peek (Vector (a, b, c, d)) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Vector (a, b, c, d, e)) Source #

poke :: Vector (a, b, c, d, e) -> Poke () Source #

peek :: Peek (Vector (a, b, c, d, e)) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Vector (a, b, c, d, e, f)) Source #

poke :: Vector (a, b, c, d, e, f) -> Poke () Source #

peek :: Peek (Vector (a, b, c, d, e, f)) Source #

Store (Vector a) => Store (Vector (Complex a)) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector (f (g a))) => Store (Vector (Compose f g a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Compose f g a)) Source #

poke :: Vector (Compose f g a) -> Poke () Source #

peek :: Peek (Vector (Compose f g a)) Source #

Store (Vector a) => Store (Vector (Min a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Min a)) Source #

poke :: Vector (Min a) -> Poke () Source #

peek :: Peek (Vector (Min a)) Source #

Store (Vector a) => Store (Vector (Max a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Max a)) Source #

poke :: Vector (Max a) -> Poke () Source #

peek :: Peek (Vector (Max a)) Source #

(Store (Vector a), Store (Vector b)) => Store (Vector (Arg a b)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Arg a b)) Source #

poke :: Vector (Arg a b) -> Poke () Source #

peek :: Peek (Vector (Arg a b)) Source #

Store (Vector a) => Store (Vector (First a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (First a)) Source #

poke :: Vector (First a) -> Poke () Source #

peek :: Peek (Vector (First a)) Source #

Store (Vector a) => Store (Vector (Last a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Last a)) Source #

poke :: Vector (Last a) -> Poke () Source #

peek :: Peek (Vector (Last a)) Source #

Store (Vector a) => Store (Vector (WrappedMonoid a)) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector a) => Store (Vector (Identity a)) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector a) => Store (Vector (Const a b)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Const a b)) Source #

poke :: Vector (Const a b) -> Poke () Source #

peek :: Peek (Vector (Const a b)) Source #

Store (Vector a) => Store (Vector (Dual a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Dual a)) Source #

poke :: Vector (Dual a) -> Poke () Source #

peek :: Peek (Vector (Dual a)) Source #

Store (Vector All) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Any) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector a) => Store (Vector (Sum a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Sum a)) Source #

poke :: Vector (Sum a) -> Poke () Source #

peek :: Peek (Vector (Sum a)) Source #

Store (Vector a) => Store (Vector (Product a)) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector (f a)) => Store (Vector (Alt f a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Alt f a)) Source #

poke :: Vector (Alt f a) -> Poke () Source #

peek :: Peek (Vector (Alt f a)) Source #

Store (Vector a) => Store (Vector (Down a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Down a)) Source #

poke :: Vector (Down a) -> Poke () Source #

peek :: Peek (Vector (Down a)) Source #

Storable a => Store (Vector a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector a) Source #

poke :: Vector a -> Poke () Source #

peek :: Peek (Vector a) Source #

Store (Vector Char) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Double) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Float) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int8) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int16) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int32) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Int64) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector (StablePtr a)) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word8) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word16) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word32) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Word64) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector (Ptr a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Ptr a)) Source #

poke :: Vector (Ptr a) -> Poke () Source #

peek :: Peek (Vector (Ptr a)) Source #

Store (Vector (FunPtr a)) Source # 
Instance details

Defined in Data.Store.Internal

Prim a => Store (Vector (Min a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Min a)) Source #

poke :: Vector (Min a) -> Poke () Source #

peek :: Peek (Vector (Min a)) Source #

Prim a => Store (Vector (Max a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Max a)) Source #

poke :: Vector (Max a) -> Poke () Source #

peek :: Peek (Vector (Max a)) Source #

Prim a => Store (Vector (First a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (First a)) Source #

poke :: Vector (First a) -> Poke () Source #

peek :: Peek (Vector (First a)) Source #

Prim a => Store (Vector (Last a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Last a)) Source #

poke :: Vector (Last a) -> Poke () Source #

peek :: Peek (Vector (Last a)) Source #

Prim a => Store (Vector (Identity a)) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CDev) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CIno) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CMode) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector COff) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CPid) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CSsize) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CGid) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CNlink) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CUid) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CCc) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CSpeed) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CTcflag) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CRLim) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CBlkSize) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CBlkCnt) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CClockId) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CFsBlkCnt) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CFsFilCnt) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CId) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CKey) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CTimer) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector Fd) Source # 
Instance details

Defined in Data.Store.Internal

Prim a => Store (Vector (Const a b)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Const a b)) Source #

poke :: Vector (Const a b) -> Poke () Source #

peek :: Peek (Vector (Const a b)) Source #

Prim a => Store (Vector (Dual a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Dual a)) Source #

poke :: Vector (Dual a) -> Poke () Source #

peek :: Peek (Vector (Dual a)) Source #

Prim a => Store (Vector (Sum a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Sum a)) Source #

poke :: Vector (Sum a) -> Poke () Source #

peek :: Peek (Vector (Sum a)) Source #

Prim a => Store (Vector (Product a)) Source # 
Instance details

Defined in Data.Store.Internal

Prim a => Store (Vector (Down a)) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector (Down a)) Source #

poke :: Vector (Down a) -> Poke () Source #

peek :: Peek (Vector (Down a)) Source #

Store (Vector CChar) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CSChar) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CUChar) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CShort) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CUShort) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CInt) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CUInt) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CLong) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CULong) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CLLong) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CULLong) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CBool) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CFloat) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CDouble) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CPtrdiff) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CSize) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CWchar) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CSigAtomic) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CClock) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CTime) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CUSeconds) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CSUSeconds) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CIntPtr) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CUIntPtr) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CIntMax) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector CUIntMax) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector WordPtr) Source # 
Instance details

Defined in Data.Store.Internal

Store (Vector IntPtr) Source # 
Instance details

Defined in Data.Store.Internal

Store a => Store (Vector a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Vector a) Source #

poke :: Vector a -> Poke () Source #

peek :: Peek (Vector a) Source #

(Store a, HasTypeHash a) => Store (Tagged a) Source # 
Instance details

Defined in Data.Store.TypeHash.Internal

Methods

size :: Size (Tagged a) Source #

poke :: Tagged a -> Poke () Source #

peek :: Peek (Tagged a) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (Either a b) Source #

poke :: Either a b -> Poke () Source #

peek :: Peek (Either a b) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (a, b) Source #

poke :: (a, b) -> Poke () Source #

peek :: Peek (a, b) Source #

(Ix i, IArray UArray e, Store i, Store e) => Store (UArray i e) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (UArray i e) Source #

poke :: UArray i e -> Poke () Source #

peek :: Peek (UArray i e) Source #

(Ix i, Store i, Store e) => Store (Array i e) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Array i e) Source #

poke :: Array i e -> Poke () Source #

peek :: Peek (Array i e) Source #

Store (Fixed a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Fixed a) Source #

poke :: Fixed a -> Poke () Source #

peek :: Peek (Fixed a) Source #

(Ord k, Store k, Store a) => Store (Map k a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Map k a) Source #

poke :: Map k a -> Poke () Source #

peek :: Peek (Map k a) Source #

(Eq k, Hashable k, Store k, Store a) => Store (HashMap k a) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (HashMap k a) Source #

poke :: HashMap k a -> Poke () Source #

peek :: Peek (HashMap k a) Source #

KnownNat n => Store (StaticSize n ByteString) Source # 
Instance details

Defined in Data.Store.Internal

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

Defined in Data.Store.Internal

Methods

size :: Size (a, b, c) Source #

poke :: (a, b, c) -> Poke () Source #

peek :: Peek (a, b, c) Source #

Store a => Store (Const a b) Source # 
Instance details

Defined in Data.Store.Internal

Methods

size :: Size (Const a b) Source #

poke :: Const a b -> Poke () Source #

peek :: Peek (Const a b) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (a, b, c, d) Source #

poke :: (a, b, c, d) -> Poke () Source #

peek :: Peek (a, b, c, d) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (a, b, c, d, e) Source #

poke :: (a, b, c, d, e) -> Poke () Source #

peek :: Peek (a, b, c, d, e) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (a, b, c, d, e, f) Source #

poke :: (a, b, c, d, e, f) -> Poke () Source #

peek :: Peek (a, b, c, d, e, f) Source #

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

Defined in Data.Store.Internal

Methods

size :: Size (a, b, c, d, e, f, g) Source #

poke :: (a, b, c, d, e, f, g) -> Poke () Source #

peek :: Peek (a, b, c, d, e, f, g) Source #

data Size a Source #

Info about a type's serialized length. Either the length is known independently of the value, or the length depends on the value.

Constructors

VarSize (a -> Int) 
ConstSize !Int 

Instances

Instances details
Contravariant Size Source # 
Instance details

Defined in Data.Store.Impl

Methods

contramap :: (a -> b) -> Size b -> Size a #

(>$) :: b -> Size b -> Size a #

data Poke a #

Poke actions are useful for building sequential serializers.

They are actions which write values to bytes into memory specified by a Ptr base. The Applicative and Monad instances make it easy to write serializations, by keeping track of the Offset of the current byte. They allow you to chain Poke action such that subsequent Pokes write into subsequent portions of the output.

Instances

Instances details
Monad Poke 
Instance details

Defined in Data.Store.Core

Methods

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

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

return :: a -> Poke a #

Functor Poke 
Instance details

Defined in Data.Store.Core

Methods

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

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

MonadFail Poke 
Instance details

Defined in Data.Store.Core

Methods

fail :: String -> Poke a #

Applicative Poke 
Instance details

Defined in Data.Store.Core

Methods

pure :: a -> Poke a #

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

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

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

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

MonadIO Poke 
Instance details

Defined in Data.Store.Core

Methods

liftIO :: IO a -> Poke a #

data Peek a #

Peek actions are useful for building sequential deserializers.

They are actions which read from memory and construct values from it. The Applicative and Monad instances make it easy to chain these together to get more complicated deserializers. This machinery keeps track of the current Ptr and end-of-buffer Ptr.

Instances

Instances details
Monad Peek 
Instance details

Defined in Data.Store.Core

Methods

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

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

return :: a -> Peek a #

Functor Peek 
Instance details

Defined in Data.Store.Core

Methods

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

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

MonadFail Peek 
Instance details

Defined in Data.Store.Core

Methods

fail :: String -> Peek a #

Applicative Peek 
Instance details

Defined in Data.Store.Core

Methods

pure :: a -> Peek a #

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

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

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

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

MonadIO Peek 
Instance details

Defined in Data.Store.Core

Methods

liftIO :: IO a -> Peek a #

PrimMonad Peek 
Instance details

Defined in Data.Store.Core

Associated Types

type PrimState Peek #

Methods

primitive :: (State# (PrimState Peek) -> (# State# (PrimState Peek), a #)) -> Peek a #

type PrimState Peek 
Instance details

Defined in Data.Store.Core

class GStoreSize f Source #

Minimal complete definition

gsize

Instances

Instances details
GStoreSize (V1 :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gsize :: Size (V1 a)

GStoreSize (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gsize :: Size (U1 a)

Store a => GStoreSize (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gsize :: Size (K1 i a a0)

(FitsInByte (SumArity (a :+: b)), GStoreSizeSum 0 (a :+: b)) => GStoreSize (a :+: b) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gsize :: Size ((a :+: b) a0)

(GStoreSize a, GStoreSize b) => GStoreSize (a :*: b) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gsize :: Size ((a :*: b) a0)

GStoreSize f => GStoreSize (M1 i c f) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gsize :: Size (M1 i c f a)

class GStorePoke f Source #

Minimal complete definition

gpoke

Instances

Instances details
GStorePoke (V1 :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpoke :: V1 a -> Poke ()

GStorePoke (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpoke :: U1 a -> Poke ()

Store a => GStorePoke (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpoke :: K1 i a a0 -> Poke ()

(FitsInByte (SumArity (a :+: b)), GStorePokeSum 0 (a :+: b)) => GStorePoke (a :+: b) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpoke :: (a :+: b) a0 -> Poke ()

(GStorePoke a, GStorePoke b) => GStorePoke (a :*: b) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpoke :: (a :*: b) a0 -> Poke ()

GStorePoke f => GStorePoke (M1 i c f) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpoke :: M1 i c f a -> Poke ()

class GStorePeek f Source #

Minimal complete definition

gpeek

Instances

Instances details
GStorePeek (V1 :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpeek :: Peek (V1 a)

GStorePeek (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpeek :: Peek (U1 a)

Store a => GStorePeek (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpeek :: Peek (K1 i a a0)

(FitsInByte (SumArity (a :+: b)), GStorePeekSum 0 (a :+: b)) => GStorePeek (a :+: b) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpeek :: Peek ((a :+: b) a0)

(GStorePeek a, GStorePeek b) => GStorePeek (a :*: b) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpeek :: Peek ((a :*: b) a0)

GStorePeek f => GStorePeek (M1 i c f) Source # 
Instance details

Defined in Data.Store.Impl

Methods

gpeek :: Peek (M1 i c f a)

Exceptions thrown by Peek

data PeekException #

Exception thrown while running peek. Note that other types of exceptions can also be thrown. Invocations of fail in the Poke monad causes this exception to be thrown.

PeekException is thrown when the data being decoded is invalid.