perdure-0.2.0: Robust persistence for acyclic immutable data

Safe HaskellSafe-Infered

Database.Perdure.Rev

Synopsis

Documentation

data a :> b Source

A data type which is equivalent to Either, but which is persisted in an open manner which allows us to chain new variants on the left. As more variants are added (going from NoRev to V1 :> NoRev and then to V2 :> V1 :> NoRev), the persisted representation gets expanded without breaking the representation of previous variants. We do not use Either because of the risk of persisting it in the standard manner and therefore losing upgradability.

Constructors

Current a 
Previous b 

Instances

Typeable2 :> 
PersistentRev (:> b r) => Persistent (:> b r) 
(Persistent b, PersistentRev r) => PersistentRev (:> b r) 
Rev b => Rev (:> a b) 

onRev :: (a -> z) -> (b -> z) -> (a :> b) -> zSource

data NoRev Source

An uninhabited type used as the last (rightmost) type in chains of '(:>)'

Instances

Typeable NoRev 
Persistent NoRev 
PersistentRev NoRev 
Rev NoRev 

toCurrent :: (b -> a) -> (a :> b) -> aSource

Converts a chain of revisions to the Current type, given a way to convert the Previous type to the Current type.

revPersister :: PersistentRev a => Persister aSource

The persister for '(:>)' first writes out the numeric index, from the right, in the chain of revisions. This way the chain of alternative revisions can lengthen without changing the indices of past revisions.

latestLens :: (b -> a) -> Lens (a :> b) aSource

This is not a legal lens since it violates the law which says that setting back what you got must have no effect. Here it is almost true since the only effect it has is to upgrade to the current representation, an idempotent change for a semantically equivalent value.