Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.UMap
Synopsis
-
data
Trip
coin ptr pool
where
- pattern Triple :: StrictMaybe coin -> Set ptr -> StrictMaybe pool -> Trip coin ptr pool
- tripReward :: Trip coin ptr pool -> Maybe coin
- tripRewardActiveDelegation :: Trip coin ptr pool -> Maybe coin
- tripDelegation :: Trip coin ptr pool -> Maybe pool
- data UMap coin cred pool ptr = UnifiedMap !( Map cred ( Trip coin ptr pool)) !( Map ptr cred)
- class UnifiedView coin cred pool ptr k v where
- umInvariant :: ( Ord cred, Ord ptr) => cred -> ptr -> UMap coin cred pool ptr -> Bool
- unView :: View coin cr pl ptr k v -> UMap coin cr pl ptr
- unUnify :: View coin cred pool ptr k v -> Map k v
- viewToVMap :: Ord cred => View coin cred pool ptr k v -> VMap VB VB k v
- rewView :: UMap coin cred pool ptr -> Map cred coin
- delView :: UMap coin cred pool ptr -> Map cred pool
- ptrView :: UMap coin cred pool ptr -> Map ptr cred
- domRestrictedView :: ( Ord ptr, Ord cred) => Set k -> View coin cred pl ptr k v -> Map k v
- zero :: Trip coin ptr pool -> Bool
- zeroMaybe :: Trip coin ptr pool -> Maybe ( Trip coin ptr pool)
- mapNext :: Map k v -> Maybe (k, v, Map k v)
- mapLub :: Ord k => k -> Map k v -> Maybe (k, v, Map k v)
- next :: View coin cr pl ptr k v -> Maybe (k, v, View coin cr pl ptr k v)
- leastUpperBound :: ( Ord ptr, Ord cr) => k -> View coin cr pool ptr k v -> Maybe (k, v, View coin cr pool ptr k v)
- empty :: UMap coin cr pool ptr
- delete :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> UMap coin cr pool ptr
- delete' :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> View coin cr pool ptr k v
- insertWith :: ( Ord cr, Monoid coin, Ord ptr) => (v -> v -> v) -> k -> v -> View coin cr pool ptr k v -> UMap coin cr pool ptr
- insertWith' :: ( Ord cr, Monoid coin, Ord ptr) => (v -> v -> v) -> k -> v -> View coin cr pool ptr k v -> View coin cr pool ptr k v
- insert :: ( Ord cr, Monoid coin, Ord ptr) => k -> v -> View coin cr pool ptr k v -> UMap coin cr pool ptr
- insert' :: ( Ord cr, Monoid coin, Ord ptr) => k -> v -> View coin cr pool ptr k v -> View coin cr pool ptr k v
- lookup :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> Maybe v
- isNull :: View coin cr pool ptr k v -> Bool
- domain :: Ord cr => View coin cr pool ptr k v -> Set k
- range :: ( Ord coin, Ord pool, Ord cr) => View coin cr pool ptr k v -> Set v
- (∪) :: ( Ord cr, Monoid coin, Ord ptr) => View coin cr pool ptr k v -> (k, v) -> UMap coin cr pool ptr
- (⨃) :: ( Ord cr, Monoid coin, Ord ptr) => View coin cr pool ptr k v -> Map k v -> UMap coin cr pool ptr
- (∪+) :: ( Ord cred, Monoid coin) => View coin cred pool ptr k coin -> Map k coin -> UMap coin cred pool ptr
- (⋪) :: ( Ord cred, Ord ptr) => Set k -> View coin cred pool ptr k v -> UMap coin cred pool ptr
- (⋫) :: ( Ord cred, Ord ptr, Ord coin, Ord pool) => View coin cred pool ptr k v -> Set v -> UMap coin cred pool ptr
- member :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> Bool
- notMember :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> Bool
- domRestrict :: ( Ord cr, Ord ptr) => View coin cr pool ptr k v -> Map k u -> Map k u
- data Tag coin cred pool ptr k v where
- data View coin cr pl ptr k v where
- findWithDefault :: ( Ord cred, Ord ptr) => a -> k -> View coin cred pool ptr k a -> a
- size :: View coin cred pool ptr k a -> Int
- unify :: ( Monoid coin, Ord cred, Ord ptr) => Map cred coin -> Map cred pool -> Map ptr cred -> UMap coin cred pool ptr
Documentation
data Trip coin ptr pool where Source #
Bundled Patterns
pattern Triple :: StrictMaybe coin -> Set ptr -> StrictMaybe pool -> Trip coin ptr pool |
Instances
tripReward :: Trip coin ptr pool -> Maybe coin Source #
tripRewardActiveDelegation :: Trip coin ptr pool -> Maybe coin Source #
tripDelegation :: Trip coin ptr pool -> Maybe pool Source #
data UMap coin cred pool ptr Source #
Constructors
UnifiedMap !( Map cred ( Trip coin ptr pool)) !( Map ptr cred) |
Instances
( Eq cred, Eq pool, Eq ptr, Eq coin) => Eq ( UMap coin cred pool ptr) Source # | |
( Show cred, Show coin, Show pool, Show ptr) => Show ( UMap coin cred pool ptr) Source # | |
Generic ( UMap coin cred pool ptr) Source # | |
(Tbor coin, Tbor ptr, Tbor cred, ToCBOR pool, Ord ptr) => ToCBOR ( UMap coin cred pool ptr) Source # | |
Defined in Data.UMap |
|
( NFData cred, NFData pool, NFData ptr, NFData coin) => NFData ( UMap coin cred pool ptr) Source # | |
( NoThunks cred, NoThunks pool, NoThunks ptr, NoThunks coin) => NoThunks ( UMap coin cred pool ptr) Source # | |
( Ord cred, FromCBOR cred, Ord ptr, FromCBOR ptr, FromCBOR coin, FromCBOR pool) => FromSharedCBOR ( UMap coin cred pool ptr) Source # | |
type Rep ( UMap coin cred pool ptr) Source # | |
Defined in Data.UMap
type
Rep
(
UMap
coin cred pool ptr) =
D1
('
MetaData
"UMap" "Data.UMap" "cardano-data-0.1.0.0-9WY2vO9HEhB6K2BmAnACTs" '
False
) (
C1
('
MetaCons
"UnifiedMap" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
(
Map
cred (
Trip
coin ptr pool)))
:*:
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
(
Map
ptr cred))))
|
|
type Share ( UMap coin cred pool ptr) Source # | |
class UnifiedView coin cred pool ptr k v where Source #
umInvariant :: ( Ord cred, Ord ptr) => cred -> ptr -> UMap coin cred pool ptr -> Bool Source #
It is worthwhie stating the invariant that holds on a Unified Map
The
ptrmap
and the
ptrT
field of the
tripmap
are inverses.
unUnify :: View coin cred pool ptr k v -> Map k v Source #
This is expensive, use it wisely (like maybe once per epoch boundary to make a SnapShot) See also domRestrictedView, which domain restricts before computing a view.
viewToVMap :: Ord cred => View coin cred pool ptr k v -> VMap VB VB k v Source #
This is expensive, use it wisely (like maybe once per epoch boundary to make a SnapShot)
domRestrictedView :: ( Ord ptr, Ord cred) => Set k -> View coin cred pl ptr k v -> Map k v Source #
Return the appropriate View of a domain restricted Umap. f
setk
is small this should be efficient.
zero :: Trip coin ptr pool -> Bool Source #
Is there no information in a Triple? If so then we can delete it from the UnifedMap
leastUpperBound :: ( Ord ptr, Ord cr) => k -> View coin cr pool ptr k v -> Maybe (k, v, View coin cr pool ptr k v) Source #
delete' :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> View coin cr pool ptr k v Source #
insertWith :: ( Ord cr, Monoid coin, Ord ptr) => (v -> v -> v) -> k -> v -> View coin cr pool ptr k v -> UMap coin cr pool ptr Source #
insertWith' :: ( Ord cr, Monoid coin, Ord ptr) => (v -> v -> v) -> k -> v -> View coin cr pool ptr k v -> View coin cr pool ptr k v Source #
Special insertion:
Keeps the value already in the ViewMap if the key
k
is already there:
insertWith' (\ old new -> old) k v xs
Replaces the value already in the ViewMap with
v
, if key
k
is already there:
insertWith' (\ old new -> new) k v xs
Replaces the value already in the ViewMap with the sum, if key
k
is already there:
insertWith' (\ old new -> old+new) k v xs
Ignores
combine
if the key
k
is NOT already in the ViewMap, and inserts
v
:
insertWith' combine k v xs
insert :: ( Ord cr, Monoid coin, Ord ptr) => k -> v -> View coin cr pool ptr k v -> UMap coin cr pool ptr Source #
insert' :: ( Ord cr, Monoid coin, Ord ptr) => k -> v -> View coin cr pool ptr k v -> View coin cr pool ptr k v Source #
(∪) :: ( Ord cr, Monoid coin, Ord ptr) => View coin cr pool ptr k v -> (k, v) -> UMap coin cr pool ptr Source #
Union with left preference, so if k, already exists, do nothing, if it doesn't exist insert it.
(⨃) :: ( Ord cr, Monoid coin, Ord ptr) => View coin cr pool ptr k v -> Map k v -> UMap coin cr pool ptr Source #
Union with right preference, so if
k
, already exists, then its value is overwritten with
v
(∪+) :: ( Ord cred, Monoid coin) => View coin cred pool ptr k coin -> Map k coin -> UMap coin cred pool ptr Source #
(⋪) :: ( Ord cred, Ord ptr) => Set k -> View coin cred pool ptr k v -> UMap coin cred pool ptr Source #
(⋫) :: ( Ord cred, Ord ptr, Ord coin, Ord pool) => View coin cred pool ptr k v -> Set v -> UMap coin cred pool ptr Source #
This is slow for Delegations and Rewards Views, better hope they are small
data View coin cr pl ptr k v where Source #
Constructors
Rewards :: !( UMap coin cr pl ptr) -> View coin cr pl ptr cr coin | |
Delegations :: !( UMap coin cr pl ptr) -> View coin cr pl ptr cr pl | |
Ptrs :: !( UMap coin cr pl ptr) -> View coin cr pl ptr ptr cr |
Instances
Foldable ( View coin cred pool ptr k) Source # | |
Defined in Data.UMap Methods fold :: Monoid m => View coin cred pool ptr k m -> m Source # foldMap :: Monoid m => (a -> m) -> View coin cred pool ptr k a -> m Source # foldMap' :: Monoid m => (a -> m) -> View coin cred pool ptr k a -> m Source # foldr :: (a -> b -> b) -> b -> View coin cred pool ptr k a -> b Source # foldr' :: (a -> b -> b) -> b -> View coin cred pool ptr k a -> b Source # foldl :: (b -> a -> b) -> b -> View coin cred pool ptr k a -> b Source # foldl' :: (b -> a -> b) -> b -> View coin cred pool ptr k a -> b Source # foldr1 :: (a -> a -> a) -> View coin cred pool ptr k a -> a Source # foldl1 :: (a -> a -> a) -> View coin cred pool ptr k a -> a Source # toList :: View coin cred pool ptr k a -> [a] Source # null :: View coin cred pool ptr k a -> Bool Source # length :: View coin cred pool ptr k a -> Int Source # elem :: Eq a => a -> View coin cred pool ptr k a -> Bool Source # maximum :: Ord a => View coin cred pool ptr k a -> a Source # minimum :: Ord a => View coin cred pool ptr k a -> a Source # sum :: Num a => View coin cred pool ptr k a -> a Source # product :: Num a => View coin cred pool ptr k a -> a Source # |