happstack-data-6.0.1: Happstack data manipulation libraries

Safe HaskellNone




class Version a whereSource

The Version type class is used to describe whether a type is fundamental or if it is meant to extend another type. For a user defined type that does not extend any others, one can use the default instance of Version, e.g. instance Version MyType to define it has having a version id of 0 and previous type.


mode :: Mode aSource

class Migrate a b whereSource

Migrate instances are needed to allow upgrades of MACID state. It should be declared as instance Migrate Old New where migrate = transition_function


migrate :: a -> bSource

data Mode a Source



Data layout won't change. Used for types like Int and Char.

Versioned (VersionId a) (Maybe (Previous a)) 

contain :: a -> Contained aSource

Lifts the provided value into Contained

extension :: forall a b. (Serialize b, Migrate b a) => VersionId a -> Proxy b -> Mode aSource

Creates a Mode that is a new version of the type carried by the provided proxy and with the provided version number. Note that since VersionId is an instance of Num that you may use int literals when calling extension, e.g. extension 1 (Proxy :: Proxy OldState)

safeGet :: forall a. Serialize a => Get aSource

Equivalent of Data.Binary.get for instances of Serialize Takes into account versioning of types.

safePut :: forall a. Serialize a => a -> PutSource

Equivalent of Data.Binary.put for instances of Serialize. Takes into account versioning of types.

getSafeGet :: forall a. Serialize a => Get (Get a)Source

getSafePut :: forall a. Serialize a => PutM (a -> Put)Source

serialize :: Serialize a => a -> ByteStringSource

Pure version of safePut. Serializes to a ByteString

deserialize :: Serialize a => ByteString -> (a, ByteString)Source

Pure version of safeGet. Parses a ByteString into the expected type and a remainder.

collectVersions :: forall a. (Typeable a, Version a) => Proxy a -> [ByteString]Source

Version lookups

data Object Source

Uniform container for any serialized data. It contains a string rep of the type and the actual data serialized to a byte string.

mkObject :: Serialize a => a -> ObjectSource

Serializes data and stores it along with its type name in an Object

parseObject :: Serialize a => Object -> aSource

Attempts to convert an Object back into its base type. If the conversion fails error will be called.