TCache-0.6.4: A Transactional data cache with configurable persistenceContentsIndex
Data.TCache.IDynamic
Description

IDynamic is a indexable and serializable version of Dynamic. (See Data.Dynamic). It is used as containers of objects in the cache so any new datatype can be incrementally stored without recompilation. IDimamic provices methods for safe casting, besides serializaton, deserialization, registrations and retrieval by lkey.

data IDynamic= forall a. (Typeable a, IResource a) => IDynamic  a deriving Typeable
Synopsis
data IDynamic = forall a . (Typeable a, IResource a) => IDynamic a
list :: MVar (Map Word (IDynamic -> IO (Maybe IDynamic), String -> IDynamic, ST IDynamic))
class DynamicInterface x where
toIDyn :: x -> IDynamic
registerType :: IO x
fromIDyn :: IDynamic -> x
unsafeFromIDyn :: IDynamic -> x
safeFromIDyn :: IDynamic -> Maybe x
data Key = Key TypeRep String
Documentation
data IDynamic
Constructors
forall a . (Typeable a, IResource a) => IDynamic a
show/hide Instances
list :: MVar (Map Word (IDynamic -> IO (Maybe IDynamic), String -> IDynamic, ST IDynamic))
class DynamicInterface x where
DynamicInterface groups a set of default method calls to handle dynamic objects. It is not necessary to derive instances from it
Methods
toIDyn
:: x
-> IDynamicencapsulates data in a dynamic object
registerType
:: IO xregisters the deserialize, readp and readResource methods for this data type
fromIDyn
:: IDynamic
-> xextract the data from the dynamic object. trows a user error when the cast fails
unsafeFromIDyn
:: IDynamic
-> xunsafe version.
safeFromIDyn
:: IDynamic
-> Maybe xsafe extraction with Maybe
data Key

Key datatype can be used to read any object trough the Dynamic interface.

 data Key =  Key TypeRep String deriving Typeable

Example

  mst <- getDResource $ Key type keyofDesiredObject
             case mst of
               Nothing -> error $ "not found "++ key
               Just (idyn) ->  fromIDyn idyn :: DesiredDatatype}
Constructors
Key TypeRep String
show/hide Instances
Produced by Haddock version 2.4.2