TCache-0.6.4: A Transactional data cache with configurable persistence

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

Documentation

data IDynamic Source

Constructors

forall a . (Typeable a, IResource a) => IDynamic a 

class DynamicInterface x whereSource

DynamicInterface groups a set of default method calls to handle dynamic objects. It is not necessary to derive instances from it

Methods

toIDynSource

Arguments

:: x 
-> IDynamic

encapsulates data in a dynamic object

registerTypeSource

Arguments

:: IO x

registers the deserialize, readp and readResource methods for this data type

fromIDynSource

Arguments

:: IDynamic 
-> x

extract the data from the dynamic object. trows a user error when the cast fails

unsafeFromIDynSource

Arguments

:: IDynamic 
-> x

unsafe version.

safeFromIDynSource

Arguments

:: IDynamic 
-> Maybe x

safe extraction with Maybe

Instances

data Key Source

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