Safe Haskell | None |
---|---|
Language | Haskell2010 |
Test.Ouroboros.Consensus.ChainGenerator.BitVector
Contents
Synopsis
- data MaybeFound base
- = NothingFound
- | JustFound !(Index base 'SlotE)
- findIthActiveInV ∷ Vector base 'SlotE S → Index base 'ActiveSlotE → MaybeFound base
- findIthEmptyInMV ∷ ∀ proxy (pol ∷ Pol) base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index base (PreImage pol 'EmptySlotE) → ST s (MaybeFound base)
- findIthEmptyInV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Index base (PreImage pol 'EmptySlotE) → MaybeFound base
- countActivesInMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → ST s (Var base (PreImage pol 'ActiveSlotE))
- countActivesInV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Size base (PreImage pol 'ActiveSlotE)
- setMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index base 'SlotE → ST s ()
- testMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index base 'SlotE → ST s Bool
- testV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Index base 'SlotE → Bool
- data SomeDensityWindow (pol ∷ Pol) = SomeDensityWindow !(Var slidingWindow (PreImage pol 'ActiveSlotE)) !(Size slidingWindow 'SlotE)
- fillInWindow ∷ ∀ proxy (pol ∷ Pol) base g s. (POL pol, StatefulGen g (ST s)) ⇒ proxy pol → SomeDensityWindow pol → g → MVector base 'SlotE s S → ST s (Var base (PreImage pol 'ActiveSlotE))
Finding
data MaybeFound base Source #
Constructors
NothingFound | |
JustFound !(Index base 'SlotE) |
Instances
Read (MaybeFound base) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector Methods readsPrec ∷ Int → ReadS (MaybeFound base) # readList ∷ ReadS [MaybeFound base] # readPrec ∷ ReadPrec (MaybeFound base) # readListPrec ∷ ReadPrec [MaybeFound base] # | |
Show (MaybeFound base) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector Methods showsPrec ∷ Int → MaybeFound base → ShowS # show ∷ MaybeFound base → String # showList ∷ [MaybeFound base] → ShowS # | |
Eq (MaybeFound base) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector Methods (==) ∷ MaybeFound base → MaybeFound base → Bool # (/=) ∷ MaybeFound base → MaybeFound base → Bool # |
findIthActiveInV ∷ Vector base 'SlotE S → Index base 'ActiveSlotE → MaybeFound base Source #
findIthEmptyInMV ∷ ∀ proxy (pol ∷ Pol) base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index base (PreImage pol 'EmptySlotE) → ST s (MaybeFound base) Source #
Find the (i+1)st empty slot in a window
findIthEmptyInMV notInverted v 0
yields the first empty slotfindIthEmptyInMV notInverted v 1
yields the second empty slotfindIthEmptyInMV notInverted v k
yields thek+1
st empty slot
findIthEmptyInMV notInverted 01101 0 == JustFound 0 findIthEmptyInMV notInverted 01101 1 == JustFound 3 findIthEmptyInMV notInverted 01101 2 == NothingFound
findIthEmptyInV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Index base (PreImage pol 'EmptySlotE) → MaybeFound base Source #
Trivial wrapper around findIthEmptyInMV
Counting
countActivesInMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → ST s (Var base (PreImage pol 'ActiveSlotE)) Source #
The number of active slots in the vector
countActivesInV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Size base (PreImage pol 'ActiveSlotE) Source #
Trivial wrapper around countActivesInMV
Slots
setMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index base 'SlotE → ST s () Source #
testMV ∷ ∀ (pol ∷ Pol) proxy base s. POL pol ⇒ proxy pol → MVector base 'SlotE s S → Index base 'SlotE → ST s Bool Source #
testV ∷ ∀ (pol ∷ Pol) proxy base. POL pol ⇒ proxy pol → Vector base 'SlotE S → Index base 'SlotE → Bool Source #
Generating
data SomeDensityWindow (pol ∷ Pol) Source #
A density of active slots in a given window
pol
is the polarity to use for the active slots
TODO: rename to SomeDensity
Constructors
SomeDensityWindow | |
Fields
|
Instances
Read (SomeDensityWindow pol) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector Methods readsPrec ∷ Int → ReadS (SomeDensityWindow pol) # readList ∷ ReadS [SomeDensityWindow pol] # readPrec ∷ ReadPrec (SomeDensityWindow pol) # readListPrec ∷ ReadPrec [SomeDensityWindow pol] # | |
Show (SomeDensityWindow pol) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector Methods showsPrec ∷ Int → SomeDensityWindow pol → ShowS # show ∷ SomeDensityWindow pol → String # showList ∷ [SomeDensityWindow pol] → ShowS # | |
Eq (SomeDensityWindow pol) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector Methods (==) ∷ SomeDensityWindow pol → SomeDensityWindow pol → Bool # (/=) ∷ SomeDensityWindow pol → SomeDensityWindow pol → Bool # |
Arguments
∷ ∀ proxy (pol ∷ Pol) base g s. (POL pol, StatefulGen g (ST s)) | |
⇒ proxy pol | |
→ SomeDensityWindow pol | |
→ g | |
→ MVector base 'SlotE s S | |
→ ST s (Var base (PreImage pol 'ActiveSlotE)) | the count after filling |
fillInWindow pol (SomeDensityWindow k s) g mv
mutates mv
to ensure
that the vector take s $ mv ++ repeat (mkActive pol)
has at least k
slots polarizely active.
Preconditions:
lengthMV mv <= s k <= s