Copyright  (c) 2016 Ertugrul Söylemez 

License  BSD3 
Maintainer  Ertugrul Söylemez <esz@posteo.de> 
Stability  experimental 
Safe Haskell  Safe 
Language  Haskell2010 
 data Predictor d s = Predictor {
 _predAgree :: d > d > Bool
 _predApply :: d > s > s
 _predLast :: s
 _predPending :: Seq (d, s)
 predictor :: (d > d > Bool) > (d > s > s) > s > Predictor d s
 predictor_ :: Eq d => (d > s > s) > s > Predictor d s
 consistent :: Predictor d s > Bool
 current :: Predictor d s > s
 lastConsistent :: Predictor d s > s
 pending :: Predictor d s > Seq (d, s)
 applyLocal :: d > Predictor d s > Predictor d s
 applyRemote :: d > Predictor d s > Predictor d s
Predictive scans
A predictor tracks information on the current state of type s
and
deltas of type d
. It records a sequence of pending local deltas
and the last state known to be consistent on both sides. As remote
deltas arrive they are reconciled with the pending local deltas.
Predictor  Warning: If you use the constructor directly, keep in mind that
for efficiency reasons this library operates under the assumption
that the second tuple components of the 

:: (d > d > Bool)  Do the given deltas agree? 
> (d > s > s)  Effect of a delta on the state. 
> s  Initial state. 
> Predictor d s 
Construct a predictor from the given functions and initial state.
A simplified variant of predictor
for cases when deltas agree when
they are equal.
Queries
consistent :: Predictor d s > Bool Source #
Is the given predictor currently consistent? Equivalently: Have all local deltas so far been acknowledged by agreeing remote deltas?
current :: Predictor d s > s Source #
The current predicted state. If the predictor is consistent
,
this will agree with lastConsistent
.
lastConsistent :: Predictor d s > s Source #
The last consistent state. If the predictor is consistent
, this
will agree with current
.
pending :: Predictor d s > Seq (d, s) Source #
Sequence of pending deltas ordered chronologically with the oldest one left together with the effect that delta is predicted to have on the state. If the predictor is consistent, this function returns the empty sequence.
Applying deltas
applyLocal :: d > Predictor d s > Predictor d s Source #
Apply the given local delta. This adds it to the sequence of pending deltas.
applyRemote :: d > Predictor d s > Predictor d s Source #
Apply the given remote delta.
If the given delta agrees with the oldest pending local delta, this function removes the latter from the pending sequence and marks the new state as the last consistent state. If it disagrees, all pending local deltas are removed and the state is reset to the last consistent state before applying the given delta.