Data.Store.Core: exported symbols usage examples

Symbols

  • decodeExPortionWith No usage example found for this symbol :( Collapse [-]
    decodeExWith No usage example found for this symbol :( Collapse [-]
    decodeIOPortionWith No usage example found for this symbol :( Collapse [-]
    decodeIOPortionWithFromPtr No usage example found for this symbol :( Collapse [-]
    decodeIOWith See 1 Occurences [+] Collapse [-]
    Found in Data.Store.Impl from the package store
    -- | Decodes a value from a 'BS.ByteString'. Returns an exception if
    -- there's an error while decoding, or if decoding undershoots /
    -- overshoots the end of the buffer.
    decode :: Store a => BS.ByteString -> Either PeekException a
    decode = unsafePerformIO . try . decodeIO
    
    -- | Decodes a value from a 'BS.ByteString', potentially throwing
    -- exceptions. It is an exception to not consume all input.
    decodeEx :: Store a => BS.ByteString -> a
    decodeEx = unsafePerformIO . decodeIO
    
    -- | Decodes a value from a 'BS.ByteString', potentially throwing
    -- exceptions. It is an exception to not consume all input.
    decodeIO :: Store a => BS.ByteString -> IO a
    decodeIO = decodeIOWith peek
    
    ------------------------------------------------------------------------
    -- Size
    
    -- | Info about a type's serialized length. Either the length is known
    

    decodeIOWithFromPtr No usage example found for this symbol :( Collapse [-]
    decodeWith No usage example found for this symbol :( Collapse [-]
    maybeAlignmentBufferSize No usage example found for this symbol :( Collapse [-]
    peekException See 2 Occurences [+] Collapse [-]
    Found in Data.Store.Impl from the package store
        {-# INLINE gpeekSum #-}
    
    instance (GStoreSize a, KnownNat n) => GStoreSizeSum n (C1 c a) where
        gsizeSum x _ = getSizeWith gsize x
        {-# INLINE gsizeSum #-}
    instance (GStorePoke a, KnownNat n) => GStorePokeSum n (C1 c a) where
        gpokeSum x _ = do
            pokeStorable (fromInteger (natVal (Proxy :: Proxy n)) :: Word8)
            gpoke x
        {-# INLINE gpokeSum #-}
    instance (GStorePeek a, KnownNat n) => GStorePeekSum n (C1 c a) where
        gpeekSum tag _
            | tag == cur = gpeek
            | tag > cur = peekException "Sum tag invalid"
            | otherwise = peekException "Error in implementation of Store Generics"
          where
            cur = fromInteger (natVal (Proxy :: Proxy n))
        {-# INLINE gpeekSum #-}
    

    Found in Data.Store.Impl from the package store
            sizeL = fromInteger (natVal (Proxy :: Proxy (n + SumArity a)))
        {-# INLINE gpeekSum #-}
    
    instance (GStoreSize a, KnownNat n) => GStoreSizeSum n (C1 c a) where
        gsizeSum x _ = getSizeWith gsize x
        {-# INLINE gsizeSum #-}
    instance (GStorePoke a, KnownNat n) => GStorePokeSum n (C1 c a) where
        gpokeSum x _ = do
            pokeStorable (fromInteger (natVal (Proxy :: Proxy n)) :: Word8)
            gpoke x
        {-# INLINE gpokeSum #-}
    instance (GStorePeek a, KnownNat n) => GStorePeekSum n (C1 c a) where
        gpeekSum tag _
            | tag == cur = gpeek
            | tag > cur = peekException "Sum tag invalid"
            | otherwise = peekException "Error in implementation of Store Generics"
          where
            cur = fromInteger (natVal (Proxy :: Proxy n))
        {-# INLINE gpeekSum #-}
    

    peekStorable See 1 Occurences [+] Collapse [-]
    Found in Data.Store.Impl from the package store
    -- FIXME: check that this type level stuff dosen't get turned into
    -- costly runtime computation
    
    instance (SumArity (a :+: b) <= 255, GStoreSizeSum 0 (a :+: b))
             => GStoreSize (a :+: b) where
        gsize = VarSize $ \x -> sizeOf (undefined :: Word8) + gsizeSum x (Proxy :: Proxy 0)
        {-# INLINE gsize #-}
    instance (SumArity (a :+: b) <= 255, GStorePokeSum 0 (a :+: b))
             => GStorePoke (a :+: b) where
        gpoke x = gpokeSum x (Proxy :: Proxy 0)
        {-# INLINE gpoke #-}
    instance (SumArity (a :+: b) <= 255, GStorePeekSum 0 (a :+: b))
             => GStorePeek (a :+: b) where
        gpeek = do
            tag <- peekStorable
            gpeekSum tag (Proxy :: Proxy 0)
        {-# INLINE gpeek #-}
    
    -- Similarly to splitting up the generic class into multiple classes, we
    -- also split up the one for sum types.
    

    peekStorableTy No usage example found for this symbol :( Collapse [-]
    peekToByteArray No usage example found for this symbol :( Collapse [-]
    peekToPlainForeignPtr No usage example found for this symbol :( Collapse [-]
    pokeException No usage example found for this symbol :( Collapse [-]
    pokeFromByteArray No usage example found for this symbol :( Collapse [-]
    pokeFromForeignPtr No usage example found for this symbol :( Collapse [-]
    pokeFromPtr No usage example found for this symbol :( Collapse [-]
    pokeStorable See 1 Occurences [+] Collapse [-]
    Found in Data.Store.Impl from the package store
    instance (GStorePeekSum n a, GStorePeekSum (n + SumArity a) b, KnownNat n)
             => GStorePeekSum n (a :+: b) where
        gpeekSum tag proxyL
            | tag < sizeL = L1 <$> gpeekSum tag proxyL
            | otherwise = R1 <$> gpeekSum tag (Proxy :: Proxy (n + SumArity a))
          where
            sizeL = fromInteger (natVal (Proxy :: Proxy (n + SumArity a)))
        {-# INLINE gpeekSum #-}
    
    instance (GStoreSize a, KnownNat n) => GStoreSizeSum n (C1 c a) where
        gsizeSum x _ = getSizeWith gsize x
        {-# INLINE gsizeSum #-}
    instance (GStorePoke a, KnownNat n) => GStorePokeSum n (C1 c a) where
        gpokeSum x _ = do
            pokeStorable (fromInteger (natVal (Proxy :: Proxy n)) :: Word8)
            gpoke x
        {-# INLINE gpokeSum #-}
    instance (GStorePeek a, KnownNat n) => GStorePeekSum n (C1 c a) where
        gpeekSum tag _
            | tag == cur = gpeek
    

    tooManyBytes No usage example found for this symbol :( Collapse [-]
    unsafeEncodeWith See 1 Occurences [+] Collapse [-]
    Found in Data.Store.Impl from the package store
        -- read issue #91.
    
    ------------------------------------------------------------------------
    -- Utilities for encoding / decoding strict ByteStrings
    
    -- | Serializes a value to a 'BS.ByteString'. In order to do this, it
    -- first allocates a 'BS.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.
    encode :: Store a => a -> BS.ByteString
    encode x = unsafeEncodeWith (poke x) (getSize x)
    
    -- | Decodes a value from a 'BS.ByteString'. Returns an exception if
    -- there's an error while decoding, or if decoding undershoots /
    -- overshoots the end of the buffer.
    decode :: Store a => BS.ByteString -> Either PeekException a
    

    unsafeMakePeekState No usage example found for this symbol :( Collapse [-]
    unsafeMakePokeState No usage example found for this symbol :( Collapse [-]
    Offset No usage example found for this symbol :( Collapse [-]
    Peek No usage example found for this symbol :( Collapse [-]
    PeekException No usage example found for this symbol :( Collapse [-]
    PeekResult No usage example found for this symbol :( Collapse [-]
    PeekState No usage example found for this symbol :( Collapse [-]
    Poke No usage example found for this symbol :( Collapse [-]
    PokeException No usage example found for this symbol :( Collapse [-]
    PokeState No usage example found for this symbol :( Collapse [-]