cardano-ledger-core-1.17.0.0: Core components of Cardano ledgers from the Shelley release on.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Ledger.UMap

Description

A UMap (for Unified map) represents

  1. 4 Maps with the same domain in one direction, as a single Map and
  2. 1 other Map which is an inverse of one of the other 4 Maps.

The advantage of using UMap is that it stores all the information compactly, by exploiting the large amount of sharing in Map #1.

As for the other Map #2, we don't expect it to have much volume.

Synopsis

Constructing a UMap

data RDPair Source #

A Reward-Deposit Pair Used to represent the reward and the deposit for a given (Credential 'Staking c)

Constructors

RDPair 

Instances

Instances details
Generic RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

Associated Types

type Rep RDPairTypeType Source #

Methods

fromRDPairRep RDPair x Source #

toRep RDPair x → RDPair Source #

Show RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

DecCBOR RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

EncCBOR RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

encCBORRDPairEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy RDPairSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [RDPair] → Size Source #

NFData RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

rnfRDPair → () Source #

Eq RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

(==)RDPairRDPairBool Source #

(/=)RDPairRDPairBool Source #

Ord RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

NoThunks RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

type Rep RDPair Source # 
Instance details

Defined in Cardano.Ledger.UMap

type Rep RDPair = D1 ('MetaData "RDPair" "Cardano.Ledger.UMap" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "RDPair" 'PrefixI 'True) (S1 ('MetaSel ('Just "rdReward") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (CompactForm Coin)) :*: S1 ('MetaSel ('Just "rdDeposit") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 (CompactForm Coin))))

data UMElem where Source #

A UMElem compactly represents the range of 4 Maps with the same domain as a single n-tuple.

This space-compacting datatype, and the pattern UMElem are equivalent to: data Elem c = Elem { rdPairT :: !(StrictMaybe RDPair), ptrT :: !(Set Ptr), sPoolT :: !(StrictMaybe (KeyHash 'StakePool c)), -- the stake pool identity dRepT :: !(StrictMaybe (DRep c)), } deriving (Show, Eq, Generic, NoThunks, NFData)

To name the constructors of UMElem we use the notation Txxx where each x is either F for full, i.e. the component is present, or E for empty, i.e. the component is not present.

There are four components: 1) the reward-deposit pair as an RDPair (CompactForm Coin) (CompactForm Coin) as a pair of Word64s, the first x, 2) the set of pointers, the second x, 3) the stake pool id (KeyHash 'StakePool c), the third x, and 4) the voting delegatee id (DRep c), the fourth x.

So, TEEEE means none of the components are present, TFEEE means only the reward-deposit pair is present, TEFEE means only the set of pointers is present, TEEFE means only the stake pool id is present. etc. TEEEF means only the voting delegatee id is present, and

The pattern UMElem will correctly use the optimal constructor.

Bundled Patterns

pattern UMElemStrictMaybe RDPairSet PtrStrictMaybe (KeyHash 'StakePool) → StrictMaybe DRepUMElem

A UMElem can be extracted and injected into the TEEEE ... TFFFF constructors.

Instances

Instances details
ToJSON UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

Generic UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

Associated Types

type Rep UMElemTypeType Source #

Methods

fromUMElemRep UMElem x Source #

toRep UMElem x → UMElem Source #

Show UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

DecShareCBOR UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

Associated Types

type Share UMElem Source #

EncCBOR UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

encCBORUMElemEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy UMElemSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [UMElem] → Size Source #

NFData UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

rnfUMElem → () Source #

Eq UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

(==)UMElemUMElemBool Source #

(/=)UMElemUMElemBool Source #

Ord UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

NoThunks UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

type Rep UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

type Rep UMElem = D1 ('MetaData "UMElem" "Cardano.Ledger.UMap" "cardano-ledger-core-1.17.0.0-inplace" 'False) ((((C1 ('MetaCons "TEEEE" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "TEEEF" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DRep))) :+: (C1 ('MetaCons "TEEFE" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool))) :+: C1 ('MetaCons "TEEFF" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DRep)))) :+: ((C1 ('MetaCons "TEFEE" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set Ptr))) :+: C1 ('MetaCons "TEFEF" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set Ptr)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DRep))) :+: (C1 ('MetaCons "TEFFE" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set Ptr)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool))) :+: C1 ('MetaCons "TEFFF" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set Ptr)) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DRep)))))) :+: (((C1 ('MetaCons "TFEEE" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 RDPair)) :+: C1 ('MetaCons "TFEEF" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 RDPair) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DRep))) :+: (C1 ('MetaCons "TFEFE" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 RDPair) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool))) :+: C1 ('MetaCons "TFEFF" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 RDPair) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DRep))))) :+: ((C1 ('MetaCons "TFFEE" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 RDPair) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set Ptr))) :+: C1 ('MetaCons "TFFEF" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 RDPair) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set Ptr)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DRep)))) :+: (C1 ('MetaCons "TFFFE" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 RDPair) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set Ptr)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool)))) :+: C1 ('MetaCons "TFFFF" 'PrefixI 'False) ((S1 ('MetaSel ('NothingMaybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 RDPair) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set Ptr))) :*: (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (KeyHash 'StakePool)) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 DRep)))))))
type Share UMElem Source # 
Instance details

Defined in Cardano.Ledger.UMap

umElemRDPairUMElemMaybe RDPair Source #

Extract the reward-deposit pair if it is present. We can tell that the reward is present when Txxxx has an F in the first position

This is equivalent to the pattern (UMElem (SJust r) _ _ _) -> Just r

umElemRDActiveUMElemMaybe RDPair Source #

Extract a delegated reward-deposit pair if it is present. We can tell that the pair is present and active when Txxxx has an F in the 1st position (present) and 3rd position (delegated).

This is equivalent to the pattern (UMElem (SJust r) _ (SJust _) _) -> Just r

umElemDRepDelegatedRewardUMElemMaybe (CompactForm Coin, DRep) Source #

Extract a DRep delegated reward if it is present. We can tell that the pair is present and active when Txxxx has an F in the 1st position (present) and 4rd position (DRep delegated).

This is equivalent to the pattern (UMElem (SJust r) _ _ (SJust d)) -> Just (r, d)

umElemDelegationsUMElemMaybe RewardDelegation Source #

Extract rewards that are either delegated to a DRep or an SPO (or both). We can tell that the pair is present and active when Txxxx has F's in the 1st and either 3rd or 4th or both positions. If there are no rewards or deposits but the delegations still exist, then we return zero coin as reward.

umElemPtrsUMElemMaybe (Set Ptr) Source #

Extract the set of pointers if it is non-empty. We can tell that the reward is present when Txxxx has an F in the second position

This is equivalent to the pattern (UMElem _ p _ _) -> Just p

umElemSPoolUMElemMaybe (KeyHash 'StakePool) Source #

Extract the stake delegatee pool id, if present. We can tell that the pool id is present when Txxxx has an F in the third position

This is equivalent to the pattern (UMElem _ _ (SJust s) _) -> Just s

umElemDRepUMElemMaybe DRep Source #

Extract the voting delegatee id, if present. We can tell that the delegatee is present when Txxxx has an F in the fourth position

This is equivalent to the pattern (UMElem _ _ _ (SJust d)) -> Just d

umElemAsTupleUMElem → (StrictMaybe RDPair, Set Ptr, StrictMaybe (KeyHash 'StakePool), StrictMaybe DRep) Source #

A n-Tuple view of the UMElem. We can view all of the constructors as an UMElem.

data UMap Source #

A unified map represents 4 Maps with domain (Credential 'Staking c)

1) Map (Credential 'Staking c) RDPair -- (RDPair rewardCoin depositCoin) 2) Map (Credential 'Staking c) (Set Ptr) 3) Map (Credential 'Staking c) (StrictMaybe (KeyHash 'StakePool c)) 4) Map (Credential 'Staking c) (StrictMaybe (DRep c)) and one more map in the inverse direction with Ptr for keys and (Credential 'Staking c) for values.

Constructors

UMap 

Instances

Instances details
ToJSON UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

Generic UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

Associated Types

type Rep UMapTypeType Source #

Methods

fromUMapRep UMap x Source #

toRep UMap x → UMap Source #

Show UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

showsPrecIntUMapShowS Source #

showUMapString Source #

showList ∷ [UMap] → ShowS Source #

DecShareCBOR UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

Associated Types

type Share UMap Source #

EncCBOR UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

encCBORUMapEncoding Source #

encodedSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy UMapSize Source #

encodedListSizeExpr ∷ (∀ t. EncCBOR t ⇒ Proxy t → Size) → Proxy [UMap] → Size Source #

NFData UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

rnfUMap → () Source #

Eq UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

(==)UMapUMapBool Source #

(/=)UMapUMapBool Source #

NoThunks UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

type Rep UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

type Rep UMap = D1 ('MetaData "UMap" "Cardano.Ledger.UMap" "cardano-ledger-core-1.17.0.0-inplace" 'False) (C1 ('MetaCons "UMap" 'PrefixI 'True) (S1 ('MetaSel ('Just "umElems") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map (Credential 'Staking) UMElem)) :*: S1 ('MetaSel ('Just "umPtrs") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map Ptr (Credential 'Staking)))))
type Share UMap Source # 
Instance details

Defined in Cardano.Ledger.UMap

emptyUMap Source #

Construct an empty UMap

umInvariantCredential 'StakingPtrUMapBool Source #

It is worthwhile stating the invariant that holds on a Unified Map. The umPtrs and the ptrT field of the umElems are inverses.

StakeCredentials

data StakeCredentials Source #

All maps unrolled. It is important to note that all fields are lazy, because conversion from UMap can be expensive, thus only fields that are forced will incur that conversion overhead.

Instances

Instances details
Generic StakeCredentials Source # 
Instance details

Defined in Cardano.Ledger.UMap

Associated Types

type Rep StakeCredentialsTypeType Source #

Show StakeCredentials Source # 
Instance details

Defined in Cardano.Ledger.UMap

NFData StakeCredentials Source # 
Instance details

Defined in Cardano.Ledger.UMap

Methods

rnfStakeCredentials → () Source #

Eq StakeCredentials Source # 
Instance details

Defined in Cardano.Ledger.UMap

NoThunks StakeCredentials Source # 
Instance details

Defined in Cardano.Ledger.UMap

type Rep StakeCredentials Source # 
Instance details

Defined in Cardano.Ledger.UMap

UView and its components

data UView k v where Source #

A UView lets one view a UMap in n different ways, one for each of the elements in a Unified Element UMElem (4) A (UView c key value) can be used like a (Map key value). It acts like a map, supporting efficient insert, delete, and lookup operations.

Instances

Instances details
Foldable (UView k) Source #

All Views are Foldable

Instance details

Defined in Cardano.Ledger.UMap

Methods

foldMonoid m ⇒ UView k m → m Source #

foldMapMonoid m ⇒ (a → m) → UView k a → m Source #

foldMap'Monoid m ⇒ (a → m) → UView k a → m Source #

foldr ∷ (a → b → b) → b → UView k a → b Source #

foldr' ∷ (a → b → b) → b → UView k a → b Source #

foldl ∷ (b → a → b) → b → UView k a → b Source #

foldl' ∷ (b → a → b) → b → UView k a → b Source #

foldr1 ∷ (a → a → a) → UView k a → a Source #

foldl1 ∷ (a → a → a) → UView k a → a Source #

toListUView k a → [a] Source #

nullUView k a → Bool Source #

lengthUView k a → Int Source #

elemEq a ⇒ a → UView k a → Bool Source #

maximumOrd a ⇒ UView k a → a Source #

minimumOrd a ⇒ UView k a → a Source #

sumNum a ⇒ UView k a → a Source #

productNum a ⇒ UView k a → a Source #

rewDepUViewMap (Credential 'Staking) UMElemMap Ptr (Credential 'Staking) → UView (Credential 'Staking) RDPair Source #

Construct a RewDepUView from the two maps that make up a UMap

ptrUViewMap (Credential 'Staking) UMElemMap Ptr (Credential 'Staking) → UView Ptr (Credential 'Staking) Source #

Construct a PtrUView from the two maps that make up a UMap

sPoolUViewMap (Credential 'Staking) UMElemMap Ptr (Credential 'Staking) → UView (Credential 'Staking) (KeyHash 'StakePool) Source #

Construct a SPoolUView from the two maps that make up a UMap

dRepUViewMap (Credential 'Staking) UMElemMap Ptr (Credential 'Staking) → UView (Credential 'Staking) DRep Source #

Construct a DRepUView from the two maps that make up a UMap

unUViewUView k v → UMap Source #

Extract the underlying UMap from a UView

unUnifyToVMapUView k v → VMap VB VB k v Source #

Materialize a real VMap (Vector Map) from a UView This is expensive, use it wisely (like maybe once per epoch boundary to make a SnapShot)

rdPairMapUMapMap (Credential 'Staking) RDPair Source #

Extract a reward-deposit pairs Map from a UMap

rewardMapUMapMap (Credential 'Staking) Coin Source #

Extract a rewards Map from a UMap

compactRewardMapUMapMap (Credential 'Staking) (CompactForm Coin) Source #

Extract a compact rewards Map from a UMap

depositMapUMapMap (Credential 'Staking) Coin Source #

Extract a deposits Map from a UMap

ptrMapUMapMap Ptr (Credential 'Staking) Source #

Extract a pointers Map from a UMap

invPtrMapUMapMap (Credential 'Staking) (Set Ptr) Source #

Extract a pointers Map from a UMap

sPoolMapUMapMap (Credential 'Staking) (KeyHash 'StakePool) Source #

Extract a stake pool delegations Map from a UMap

dRepMapUMapMap (Credential 'Staking) DRep Source #

Extract a delegated-representatives Map from a UMap

domRestrictedMapSet k → UView k v → Map k v Source #

Extract a domain-restricted Map of a UMap. If `Set k` is small this should be efficient.

data family CompactForm a ∷ Type Source #

Instances

Instances details
FromJSON (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

ToJSON (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

ToJSON (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Monoid (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Semigroup (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Show (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Show (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

ToCBOR (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Methods

toCBORCompactForm CoinEncoding Source #

encodedSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy (CompactForm Coin) → Size Source #

encodedListSizeExpr ∷ (∀ t. ToCBOR t ⇒ Proxy t → Size) → Proxy [CompactForm Coin] → Size Source #

DecCBOR (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

DecCBOR (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

EncCBOR (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

EncCBOR (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

NFData (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Methods

rnfCompactForm Coin → () Source #

NFData (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Methods

rnfCompactForm DeltaCoin → () Source #

Eq (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Eq (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Ord (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Abelian (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Group (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

HeapWords (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

HeapWords (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

NoThunks (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

NoThunks (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Prim (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Prim (CompactForm DeltaCoin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Uniform (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

Methods

uniformMStatefulGen g m ⇒ g → m (CompactForm Coin) Source #

UniformRange (CompactForm Coin) Source # 
Instance details

Defined in Cardano.Ledger.Coin

newtype CompactForm Coin Source # 
Instance details

Defined in Cardano.Ledger.Coin

newtype CompactForm DeltaCoin Source # 
Instance details

Defined in Cardano.Ledger.Coin

unifyMap (Credential 'Staking) RDPairMap Ptr (Credential 'Staking) → Map (Credential 'Staking) (KeyHash 'StakePool) → Map (Credential 'Staking) DRepUMap Source #

Create a UMap from 4 separate maps. NOTE: For use in tests only.

unUnifyUView k v → Map k v Source #

Materialize a real Map from a View This is expensive, use it wisely (like maybe once per epoch boundary to make a SnapShot) See also domRestrictedMap, which domain-restricts before computing a view.

Set and Map operations on UViews

nullUViewUView k v → Bool Source #

null for a UView, just like null

member ∷ k → UView k v → Bool Source #

Membership check for a UView, just like member

Spec: eval (k ∈ dom (rewards dState)) eval (k ∈ dom (rewards ds))) eval (hk ∈ dom (rewards ds)) eval (hk ∉ dom (rewards ds))

member'Credential 'StakingUMapBool Source #

Checks for membership directly against umElems instead of a UView.

notMember ∷ k → UView k v → Bool Source #

Membership check for a UView, just like member

Spec: eval (k ∈ dom (rewards dState)) eval (k ∈ dom (rewards ds))) eval (hk ∈ dom (rewards ds)) eval (hk ∉ dom (rewards ds))

delete ∷ k → UView k v → UMap Source #

delete' ∷ k → UView k v → UView k v Source #

Delete a key and its value from the map-like UView, returning a version of the same UView.

In the case of a PtrUView we maintain the umInvariant and delete the pairs from both umElems as well as umPtrs of the UMap.

insertWith ∷ (v → v → v) → k → v → UView k v → UMap Source #

insertWith' ∷ (v → v → v) → k → v → UView k v → UView k v Source #

Insert with combination

If k exists as a key in the (map-like) UView:

  1. to keep the old value > insertWith' ( old new -> old) k v view
  2. to replace the old value with the new value > insertWith' ( old new -> new) k v view
  3. to combine the old and new values with summation > insertWith' ( old new -> old + new) k v view

If k does not exist as a key in the UView, the combining function is ignored, and the key k and the value v are inserted into the map-like UView > insertWith' ignoredCombiningFunction k v view

insert ∷ k → v → UView k v → UMap Source #

insert' ∷ k → v → UView k v → UView k v Source #

adjust ∷ (RDPairRDPair) → k → UView k RDPairUMap Source #

Adjust a UView, just like adjust. This is implemented only for reward-deposit pairs.

lookup ∷ k → UView k v → Maybe v Source #

Lookup a UView, just like lookup.

domainUView k v → Set k Source #

Get the domain of the Map-like UView

rangeUView k v → Set v Source #

Get the range of the Map-like UView

(∪)UView k v → (k, v) → UMap Source #

Union with left preference. So if k, already exists, do nothing, if it doesn't exist insert it.

Spec: evalUnified (RewDepUView u1 ∪ singleton hk mempty) evalUnified (Ptrs u2 ∪ singleton ptr hk)

unionLUView k v → (k, v) → UMap Source #

Union with left preference. So if k, already exists, do nothing, if it doesn't exist insert it.

Spec: evalUnified (RewDepUView u1 ∪ singleton hk mempty) evalUnified (Ptrs u2 ∪ singleton ptr hk)

(⨃)UView k v → Map k v → UMap Source #

Union with right preference. So if k, already exists, then old v is overwritten with the new v.

Special rules apply for the RewDepUView, where only the rdReward field of the RDPair is overwritten, and the old rdDeposit value persists.

Note: In this case it is an invariant that the domain of the Map on the right side is a subset of the domain of the RewDepUView. See the single case in module Cardano.Ledger.Shelley.Rules.Delegs, in the dealing with Withdrawals's where it is used at this type.

Spec: evalUnified (delegations ds ⨃ singleton hk dpool) evalUnified (rewards' ⨃ wdrls_')

unionRUView k v → Map k v → UMap Source #

Union with right preference. So if k, already exists, then old v is overwritten with the new v.

Special rules apply for the RewDepUView, where only the rdReward field of the RDPair is overwritten, and the old rdDeposit value persists.

Note: In this case it is an invariant that the domain of the Map on the right side is a subset of the domain of the RewDepUView. See the single case in module Cardano.Ledger.Shelley.Rules.Delegs, in the dealing with Withdrawals's where it is used at this type.

Spec: evalUnified (delegations ds ⨃ singleton hk dpool) evalUnified (rewards' ⨃ wdrls_')

(∪+)UView (Credential 'Staking) RDPairMap (Credential 'Staking) (CompactForm Coin) → UMap Source #

Add the reward from the Map on the right side to the reward in the UView on the left. This is only implemented and is applicable to RewDepUViews.

We presume that the domain of the Map on the right, is a subset of the domain of the UView on the left.

Spec: evalUnified (rewards dState ∪+ registeredAggregated) evalUnified (rewards' ∪+ update) evalUnified (RewDepUView u0 ∪+ refunds)

unionRewAggUView (Credential 'Staking) RDPairMap (Credential 'Staking) (CompactForm Coin) → UMap Source #

Add the reward from the Map on the right side to the reward in the UView on the left. This is only implemented and is applicable to RewDepUViews.

We presume that the domain of the Map on the right, is a subset of the domain of the UView on the left.

Spec: evalUnified (rewards dState ∪+ registeredAggregated) evalUnified (rewards' ∪+ update) evalUnified (RewDepUView u0 ∪+ refunds)

unionKeyDepositsUView k RDPairMap k (CompactForm Coin) → UMap Source #

Add the deposit from the Map on the right side to the deposit in the UView on the left. This is only implemented and is applicable to RewDepUViews.

(⋪)Set k → UView k v → UMap Source #

Delete all keys in the given Set from the domain of the given map-like UView.

Spec: evalUnified (setSingleton hk ⋪ RewDepUView u0) evalUnified (setSingleton hk ⋪ SPoolUView u1)

domDeleteSet k → UView k v → UMap Source #

Delete all keys in the given Set from the domain of the given map-like UView.

Spec: evalUnified (setSingleton hk ⋪ RewDepUView u0) evalUnified (setSingleton hk ⋪ SPoolUView u1)

(⋫)UView k v → Set v → UMap Source #

Delete all elements in the given Set from the range of the given map-like UView. This is slow for SPoolUView, RewDepUView, and DReps UViews, better hope the sets are small

Spec: evalUnified (Ptrs u2 ⋫ setSingleton hk) evalUnified (SPoolUView u1 ⋫ retired)

rngDeleteUView k v → Set v → UMap Source #

Delete all elements in the given Set from the range of the given map-like UView. This is slow for SPoolUView, RewDepUView, and DReps UViews, better hope the sets are small

Spec: evalUnified (Ptrs u2 ⋫ setSingleton hk) evalUnified (SPoolUView u1 ⋫ retired)

(◁)UView k v → Map k u → Map k u Source #

Domain restriction.

Spec: eval (dom rewards' ◁ iRReserves (_irwd ds) :: RewardAccounts (Crypto era)) eval (dom rewards' ◁ iRTreasury (_irwd ds) :: RewardAccounts (Crypto era))

domRestrictUView k v → Map k u → Map k u Source #

Domain restriction.

Spec: eval (dom rewards' ◁ iRReserves (_irwd ds) :: RewardAccounts (Crypto era)) eval (dom rewards' ◁ iRTreasury (_irwd ds) :: RewardAccounts (Crypto era))

Derived functions

findWithDefault ∷ v → k → UView k v → v Source #

Find the value associated with a key from a UView, return the default if the key is not there.

sizeUView k v → Int Source #

A UView is a view, so the size of the view is NOT the same as the size of the underlying UMElem map.

domDeleteAllSet (Credential 'Staking) → UMapUMap Source #

Delete the stake credentials in the domain and all associated ranges from the UMap This can be expensive when there are many pointers associated with the credential.

deleteStakingCredentialCredential 'StakingUMapUMap Source #

Completely remove the staking credential from the UMap, including all associated pointers.

extractStakingCredentialCredential 'StakingUMap → (Maybe UMElem, UMap) Source #

Just like deleteStakingCredential, but also returned the removed element.