Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides utilities which help ensure that we aren't
attempting to de-serialize data that is an older or newer version.
The WithVersion
utility wraps up a datatype along with a version
tag. This version tag can either be provided by the user
(namedVersionConfig
), or use a computed hash
(hashedVersionConfig
).
The magic here is using an SYB traversal (Data
) to get the
structure of all the data-types involved. This info is rendered to
text and hashed to yield a hash which describes it.
NOTE that this API is still quite new and so is likely to break compatibility in the future. It should also be expected that the computed hashes may change between major version bumps, though this will be minimized when directly feasible.
Synopsis
- newtype StoreVersion = StoreVersion {}
- data VersionConfig a = VersionConfig {}
- hashedVersionConfig :: String -> VersionConfig a
- namedVersionConfig :: String -> String -> VersionConfig a
- encodeWithVersionQ :: Data a => VersionConfig a -> Q Exp
- decodeWithVersionQ :: Data a => VersionConfig a -> Q Exp
Documentation
newtype StoreVersion Source #
Instances
data VersionConfig a Source #
Configuration for the version checking of a particular type.
VersionConfig | |
|
Instances
hashedVersionConfig :: String -> VersionConfig a Source #
namedVersionConfig :: String -> String -> VersionConfig a Source #
encodeWithVersionQ :: Data a => VersionConfig a -> Q Exp Source #
decodeWithVersionQ :: Data a => VersionConfig a -> Q Exp Source #