Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data MaybeFound base
- = NothingFound
- | JustFound !(Index base SlotE)
- findIthActiveInV ∷ Vector base SlotE S → Index base ActiveSlotE → MaybeFound base
- findIthEmptyInMV ∷ ∀ proxy 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 pol → Vector base SlotE S → Index base (PreImage pol EmptySlotE) → MaybeFound base
- countActivesInMV ∷ POL pol ⇒ proxy pol → MVector base SlotE s S → ST s (Var base (PreImage pol ActiveSlotE))
- countActivesInV ∷ POL pol ⇒ proxy pol → Vector base SlotE S → Size base (PreImage pol ActiveSlotE)
- setMV ∷ POL pol ⇒ proxy pol → MVector base SlotE s S → Index base SlotE → ST s ()
- testMV ∷ POL pol ⇒ proxy pol → MVector base SlotE s S → Index base SlotE → ST s Bool
- testV ∷ POL pol ⇒ proxy pol → Vector base SlotE S → Index base SlotE → Bool
- data SomeDensityWindow pol = ∀ slidingWindow. SomeDensityWindow !(Var slidingWindow (PreImage pol ActiveSlotE)) !(Size slidingWindow SlotE)
- fillInWindow ∷ ∀ proxy 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 #
NothingFound | |
JustFound !(Index base SlotE) |
Instances
Read (MaybeFound base) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector 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 showsPrec ∷ Int → MaybeFound base → ShowS # show ∷ MaybeFound base → String # showList ∷ [MaybeFound base] → ShowS # | |
Eq (MaybeFound base) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector (==) ∷ MaybeFound base → MaybeFound base → Bool # (/=) ∷ MaybeFound base → MaybeFound base → Bool # |
findIthActiveInV ∷ Vector base SlotE S → Index base ActiveSlotE → MaybeFound base Source #
findIthEmptyInMV ∷ ∀ proxy 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 pol → Vector base SlotE S → Index base (PreImage pol EmptySlotE) → MaybeFound base Source #
Trivial wrapper around findIthEmptyInMV
Counting
countActivesInMV ∷ 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 pol → Vector base SlotE S → Size base (PreImage pol ActiveSlotE) Source #
Trivial wrapper around countActivesInMV
Slots
Generating
data SomeDensityWindow 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
∀ slidingWindow. SomeDensityWindow | |
|
Instances
Read (SomeDensityWindow pol) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector 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 showsPrec ∷ Int → SomeDensityWindow pol → ShowS # show ∷ SomeDensityWindow pol → String # showList ∷ [SomeDensityWindow pol] → ShowS # | |
Eq (SomeDensityWindow pol) Source # | |
Defined in Test.Ouroboros.Consensus.ChainGenerator.BitVector (==) ∷ SomeDensityWindow pol → SomeDensityWindow pol → Bool # (/=) ∷ SomeDensityWindow pol → SomeDensityWindow pol → Bool # |
∷ ∀ proxy 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