| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Util.AnchoredSeq
Description
Utilities on AnchoredSeqs.
Synopsis
- takeLongestSuffix ∷ (Monoid s, Anchorable v a b) ⇒ (AnchoredSeq v a b → s) → (s → Bool) → AnchoredSeq v a b → AnchoredSeq v a b
Documentation
Arguments
| ∷ (Monoid s, Anchorable v a b) | |
| ⇒ (AnchoredSeq v a b → s) |
|
| → (s → Bool) |
|
| → AnchoredSeq v a b | Input sequence |
| → AnchoredSeq v a b | A suffix of the input sequence. |
Take the longest suffix of an AnchoredSeq as satisfying the given
predicate p on the monoidal summary given by f.
TODO: upstream this function
PRECONDITIONS:
For as0, as1 such that AS.join as0 as1 = Just as2, we must have the
following homomorphism property:
f as0 <> f as1 ≡ f as2
For empty ase, we must have f ase ≡ mempty.
The predicate must be monotonic, ie when suf0 is a suffix of as and
suf1 is a suffix of suf0, then p (f suf0) must imply p (f suf1).
Furthermore, we must have p mempty.