Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module contains the definition of point schedule _peers_ as well as all kind of utilities to manipulate them.
Synopsis
- data Peer a = Peer {}
- data PeerId
- data Peers a = Peers {}
- enumerateAdversaries ∷ [PeerId]
- fromMap ∷ Map PeerId (Peer a) → Peers a
- fromMap' ∷ Map PeerId a → Peers a
- getPeer ∷ PeerId → Peers a → Peer a
- getPeerIds ∷ Peers a → NonEmpty PeerId
- mkPeers ∷ a → [a] → Peers a
- mkPeers' ∷ a → [Peer a] → Peers a
- peersFromPeerIdList ∷ NonEmpty PeerId → a → Peers a
- peersFromPeerIdList' ∷ NonEmpty PeerId → Peers ()
- peersFromPeerList ∷ NonEmpty (Peer a) → Peers a
- peersList ∷ Peers a → NonEmpty (Peer a)
- peersOnlyHonest ∷ a → Peers a
- toMap ∷ Peers a → Map PeerId (Peer a)
- toMap' ∷ Peers a → Map PeerId a
- updatePeer ∷ (a → a) → PeerId → Peers a → Peers a
Documentation
General-purpose functor associated with a peer.
Instances
Foldable Peer Source # | |
Defined in Test.Consensus.PointSchedule.Peers fold ∷ Monoid m ⇒ Peer m → m # foldMap ∷ Monoid m ⇒ (a → m) → Peer a → m # foldMap' ∷ Monoid m ⇒ (a → m) → Peer a → m # foldr ∷ (a → b → b) → b → Peer a → b # foldr' ∷ (a → b → b) → b → Peer a → b # foldl ∷ (b → a → b) → b → Peer a → b # foldl' ∷ (b → a → b) → b → Peer a → b # foldr1 ∷ (a → a → a) → Peer a → a # foldl1 ∷ (a → a → a) → Peer a → a # elem ∷ Eq a ⇒ a → Peer a → Bool # maximum ∷ Ord a ⇒ Peer a → a # | |
Traversable Peer Source # | |
Functor Peer Source # | |
Show a ⇒ Show (Peer a) Source # | |
Eq a ⇒ Eq (Peer a) Source # | |
Condense a ⇒ Condense (Peer a) Source # | |
CondenseList a ⇒ CondenseList (Peer a) Source # | |
Defined in Test.Consensus.PointSchedule.Peers condenseList ∷ [Peer a] → [String] Source # |
Identifier used to index maps and specify which peer is active during a tick.
Instances
IsString PeerId Source # | |
Defined in Test.Consensus.PointSchedule.Peers fromString ∷ String → PeerId # | |
Generic PeerId Source # | |
Show PeerId Source # | |
Eq PeerId Source # | |
Ord PeerId Source # | |
Hashable PeerId Source # | |
Condense PeerId Source # | |
CondenseList PeerId Source # | |
Defined in Test.Consensus.PointSchedule.Peers condenseList ∷ [PeerId] → [String] Source # | |
type Rep PeerId Source # | |
Defined in Test.Consensus.PointSchedule.Peers type Rep PeerId = D1 ('MetaData "PeerId" "Test.Consensus.PointSchedule.Peers" "main" 'False) (C1 ('MetaCons "HonestPeer" 'PrefixI 'False) (U1 ∷ Type → Type) :+: C1 ('MetaCons "PeerId" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))) |
General-purpose functor for a set of peers.
REVIEW: There is a duplicate entry for the honest peer, here. We should
probably either have only the Map
or have the keys of the map be String
?
Alternatively, we could just have 'newtype PeerId = PeerId String' with an alias for 'HonestPeer = PeerId "honest"'?
mkPeers ∷ a → [a] → Peers a Source #
Construct Peers
from values, adding adversary names based on the default schema.
A single adversary gets the ID adversary
, multiple get enumerated as adversary N
.
mkPeers' ∷ a → [Peer a] → Peers a Source #
Make a Peers
structure from the honest value and the other peers. Fail if
one of the other peers is the HonestPeer
.
peersFromPeerIdList ∷ NonEmpty PeerId → a → Peers a Source #
Make a Peers
structure from a non-empty list of peer ids and a default
value. Fails if the honest peer is not exactly once in the list.
peersFromPeerIdList' ∷ NonEmpty PeerId → Peers () Source #
Like peersFromPeerIdList
with ()
.
peersFromPeerList ∷ NonEmpty (Peer a) → Peers a Source #
Make a Peers
structure from a non-empty list of peers. Fail if the honest
peer is not exactly once in the list.
peersOnlyHonest ∷ a → Peers a Source #
A set of peers with only one honest peer carrying the given value.