cardano-data-0.1.0.0: Specialized data for Cardano project
Safe Haskell None
Language Haskell2010

Data.UMap

Synopsis

Documentation

data Trip coin ptr pool where Source #

Bundled Patterns

pattern Triple :: StrictMaybe coin -> Set ptr -> StrictMaybe pool -> Trip coin ptr pool

Instances

Instances details
( Eq pool, Eq ptr, Eq coin) => Eq ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

Methods

(==) :: Trip coin ptr pool -> Trip coin ptr pool -> Bool Source #

(/=) :: Trip coin ptr pool -> Trip coin ptr pool -> Bool Source #

( Ord pool, Ord ptr, Ord coin) => Ord ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

Methods

compare :: Trip coin ptr pool -> Trip coin ptr pool -> Ordering Source #

(<) :: Trip coin ptr pool -> Trip coin ptr pool -> Bool Source #

(<=) :: Trip coin ptr pool -> Trip coin ptr pool -> Bool Source #

(>) :: Trip coin ptr pool -> Trip coin ptr pool -> Bool Source #

(>=) :: Trip coin ptr pool -> Trip coin ptr pool -> Bool Source #

max :: Trip coin ptr pool -> Trip coin ptr pool -> Trip coin ptr pool Source #

min :: Trip coin ptr pool -> Trip coin ptr pool -> Trip coin ptr pool Source #

( Show coin, Show pool, Show ptr) => Show ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

Generic ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

Associated Types

type Rep ( Trip coin ptr pool) :: Type -> Type Source #

Methods

from :: Trip coin ptr pool -> Rep ( Trip coin ptr pool) x Source #

to :: Rep ( Trip coin ptr pool) x -> Trip coin ptr pool Source #

( Ord ptr, Monoid coin) => Semigroup ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

Methods

(<>) :: Trip coin ptr pool -> Trip coin ptr pool -> Trip coin ptr pool Source #

sconcat :: NonEmpty ( Trip coin ptr pool) -> Trip coin ptr pool Source #

stimes :: Integral b => b -> Trip coin ptr pool -> Trip coin ptr pool Source #

( Ord ptr, Monoid coin) => Monoid ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

Methods

mempty :: Trip coin ptr pool Source #

mappend :: Trip coin ptr pool -> Trip coin ptr pool -> Trip coin ptr pool Source #

mconcat :: [ Trip coin ptr pool] -> Trip coin ptr pool Source #

(Tbor coin, Tbor ptr, Ord ptr, ToCBOR pool) => ToCBOR ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

( NFData pool, NFData ptr, NFData coin) => NFData ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

Methods

rnf :: Trip coin ptr pool -> () Source #

( NoThunks pool, NoThunks ptr, NoThunks coin) => NoThunks ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

( FromCBOR coin, Ord ptr, FromCBOR ptr, FromCBOR pool) => FromSharedCBOR ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

Associated Types

type Share ( Trip coin ptr pool) Source #

Methods

getShare :: Trip coin ptr pool -> Share ( Trip coin ptr pool) Source #

fromSharedCBOR :: Share ( Trip coin ptr pool) -> Decoder s ( Trip coin ptr pool) Source #

fromSharedPlusCBOR :: StateT ( Share ( Trip coin ptr pool)) ( Decoder s) ( Trip coin ptr pool) Source #

type Rep ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

type Rep ( Trip coin ptr pool) = D1 (' MetaData "Trip" "Data.UMap" "cardano-data-0.1.0.0-9WY2vO9HEhB6K2BmAnACTs" ' False ) ((( C1 (' MetaCons "TEEE" ' PrefixI ' False ) ( U1 :: Type -> Type ) :+: C1 (' MetaCons "TEEF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 pool))) :+: ( C1 (' MetaCons "TEFE" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Set ptr))) :+: C1 (' MetaCons "TEFF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Set ptr)) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 pool)))) :+: (( C1 (' MetaCons "TFEE" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 coin)) :+: C1 (' MetaCons "TFEF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 coin) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 pool))) :+: ( C1 (' MetaCons "TFFE" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 coin) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Set ptr))) :+: C1 (' MetaCons "TFFF" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 coin) :*: ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Set ptr)) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 pool))))))
type Share ( Trip coin ptr pool) Source #
Instance details

Defined in Data.UMap

type Share ( Trip coin ptr pool) = Interns pool

data UMap coin cred pool ptr Source #

Constructors

UnifiedMap !( Map cred ( Trip coin ptr pool)) !( Map ptr cred)

Instances

Instances details
( Eq cred, Eq pool, Eq ptr, Eq coin) => Eq ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

Methods

(==) :: UMap coin cred pool ptr -> UMap coin cred pool ptr -> Bool Source #

(/=) :: UMap coin cred pool ptr -> UMap coin cred pool ptr -> Bool Source #

( Show cred, Show coin, Show pool, Show ptr) => Show ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

Methods

showsPrec :: Int -> UMap coin cred pool ptr -> ShowS Source #

show :: UMap coin cred pool ptr -> String Source #

showList :: [ UMap coin cred pool ptr] -> ShowS Source #

Generic ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

Associated Types

type Rep ( UMap coin cred pool ptr) :: Type -> Type Source #

Methods

from :: UMap coin cred pool ptr -> Rep ( UMap coin cred pool ptr) x Source #

to :: Rep ( UMap coin cred pool ptr) x -> UMap coin cred pool ptr Source #

(Tbor coin, Tbor ptr, Tbor cred, ToCBOR pool, Ord ptr) => ToCBOR ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

Methods

toCBOR :: UMap coin cred pool ptr -> Encoding Source #

encodedSizeExpr :: ( forall t. ToCBOR t => Proxy t -> Size ) -> Proxy ( UMap coin cred pool ptr) -> Size Source #

encodedListSizeExpr :: ( forall t. ToCBOR t => Proxy t -> Size ) -> Proxy [ UMap coin cred pool ptr] -> Size Source #

( NFData cred, NFData pool, NFData ptr, NFData coin) => NFData ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

Methods

rnf :: UMap coin cred pool ptr -> () Source #

( NoThunks cred, NoThunks pool, NoThunks ptr, NoThunks coin) => NoThunks ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

( Ord cred, FromCBOR cred, Ord ptr, FromCBOR ptr, FromCBOR coin, FromCBOR pool) => FromSharedCBOR ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

Associated Types

type Share ( UMap coin cred pool ptr) Source #

Methods

getShare :: UMap coin cred pool ptr -> Share ( UMap coin cred pool ptr) Source #

fromSharedCBOR :: Share ( UMap coin cred pool ptr) -> Decoder s ( UMap coin cred pool ptr) Source #

fromSharedPlusCBOR :: StateT ( Share ( UMap coin cred pool ptr)) ( Decoder s) ( UMap coin cred pool ptr) Source #

type Rep ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

type Share ( UMap coin cred pool ptr) Source #
Instance details

Defined in Data.UMap

type Share ( UMap coin cred pool ptr) = ( Interns cred, Interns pool)

class UnifiedView coin cred pool ptr k v where Source #

Methods

tag :: Tag coin cred pool ptr k v 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.

unView :: View coin cr pl ptr k v -> UMap coin cr pl ptr Source #

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)

rewView :: UMap coin cred pool ptr -> Map cred coin Source #

delView :: UMap coin cred pool ptr -> Map cred pool Source #

ptrView :: UMap coin cred pool ptr -> Map ptr cred Source #

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

zeroMaybe :: Trip coin ptr pool -> Maybe ( Trip coin ptr pool) Source #

next :: View coin cr pl ptr k v -> Maybe (k, v, View coin cr pl ptr k v) Source #

leastUpperBound :: ( Ord ptr, Ord cr) => k -> View coin cr pool ptr k v -> Maybe (k, v, View coin cr pool ptr k v) Source #

empty :: UMap coin cr pool ptr Source #

delete :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> UMap coin cr pool ptr 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 #

lookup :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> Maybe v Source #

isNull :: View coin cr pool ptr k v -> Bool Source #

domain :: Ord cr => View coin cr pool ptr k v -> Set k Source #

range :: ( Ord coin, Ord pool, Ord cr) => View coin cr pool ptr k v -> Set 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

member :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> Bool Source #

notMember :: ( Ord cr, Ord ptr) => k -> View coin cr pool ptr k v -> Bool Source #

domRestrict :: ( Ord cr, Ord ptr) => View coin cr pool ptr k v -> Map k u -> Map k u Source #

data Tag coin cred pool ptr k v where Source #

Constructors

Rew :: Tag coin cred pool ptr cred coin
Del :: Tag coin cred pool ptr cred pool
Ptr :: Tag coin cred pool ptr ptr cred

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

Instances details
Foldable ( View coin cred pool ptr k) Source #
Instance details

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 #

findWithDefault :: ( Ord cred, Ord ptr) => a -> k -> View coin cred pool ptr k a -> a Source #

size :: View coin cred pool ptr k a -> Int Source #

A View is a view, so the size of the view is NOT the same as the size of the underlying triple map.

unify :: ( Monoid coin, Ord cred, Ord ptr) => Map cred coin -> Map cred pool -> Map ptr cred -> UMap coin cred pool ptr Source #

Create a UMap from 3 separate maps. For use in tests only.