{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilies #-}
module GHC.Cmm.Dataflow.Collections
( IsSet(..)
, setInsertList, setDeleteList, setUnions
, IsMap(..)
, mapInsertList, mapDeleteList, mapUnions
, UniqueMap, UniqueSet
) where
import GHC.Prelude
import qualified GHC.Data.Word64Map.Strict as M
import qualified GHC.Data.Word64Set as S
import Data.List (foldl1')
import Data.Word (Word64)
class IsSet set where
type ElemOf set
setNull :: set -> Bool
setSize :: set -> Int
setMember :: ElemOf set -> set -> Bool
setEmpty :: set
setSingleton :: ElemOf set -> set
setInsert :: ElemOf set -> set -> set
setDelete :: ElemOf set -> set -> set
setUnion :: set -> set -> set
setDifference :: set -> set -> set
setIntersection :: set -> set -> set
setIsSubsetOf :: set -> set -> Bool
setFilter :: (ElemOf set -> Bool) -> set -> set
setFoldl :: (b -> ElemOf set -> b) -> b -> set -> b
setFoldr :: (ElemOf set -> b -> b) -> b -> set -> b
setElems :: set -> [ElemOf set]
setFromList :: [ElemOf set] -> set
setInsertList :: IsSet set => [ElemOf set] -> set -> set
setInsertList :: forall set. IsSet set => [ElemOf set] -> set -> set
setInsertList [ElemOf set]
keys set
set = (set -> ElemOf set -> set) -> set -> [ElemOf set] -> set
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ((ElemOf set -> set -> set) -> set -> ElemOf set -> set
forall a b c. (a -> b -> c) -> b -> a -> c
flip ElemOf set -> set -> set
forall set. IsSet set => ElemOf set -> set -> set
setInsert) set
set [ElemOf set]
keys
setDeleteList :: IsSet set => [ElemOf set] -> set -> set
setDeleteList :: forall set. IsSet set => [ElemOf set] -> set -> set
setDeleteList [ElemOf set]
keys set
set = (set -> ElemOf set -> set) -> set -> [ElemOf set] -> set
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ((ElemOf set -> set -> set) -> set -> ElemOf set -> set
forall a b c. (a -> b -> c) -> b -> a -> c
flip ElemOf set -> set -> set
forall set. IsSet set => ElemOf set -> set -> set
setDelete) set
set [ElemOf set]
keys
setUnions :: IsSet set => [set] -> set
setUnions :: forall set. IsSet set => [set] -> set
setUnions [] = set
forall set. IsSet set => set
setEmpty
setUnions [set]
sets = (set -> set -> set) -> [set] -> set
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' set -> set -> set
forall set. IsSet set => set -> set -> set
setUnion [set]
sets
class IsMap map where
type KeyOf map
mapNull :: map a -> Bool
mapSize :: map a -> Int
mapMember :: KeyOf map -> map a -> Bool
mapLookup :: KeyOf map -> map a -> Maybe a
mapFindWithDefault :: a -> KeyOf map -> map a -> a
mapEmpty :: map a
mapSingleton :: KeyOf map -> a -> map a
mapInsert :: KeyOf map -> a -> map a -> map a
mapInsertWith :: (a -> a -> a) -> KeyOf map -> a -> map a -> map a
mapDelete :: KeyOf map -> map a -> map a
mapAlter :: (Maybe a -> Maybe a) -> KeyOf map -> map a -> map a
mapAdjust :: (a -> a) -> KeyOf map -> map a -> map a
mapUnion :: map a -> map a -> map a
mapUnionWithKey :: (KeyOf map -> a -> a -> a) -> map a -> map a -> map a
mapDifference :: map a -> map a -> map a
mapIntersection :: map a -> map a -> map a
mapIsSubmapOf :: Eq a => map a -> map a -> Bool
mapMap :: (a -> b) -> map a -> map b
mapMapWithKey :: (KeyOf map -> a -> b) -> map a -> map b
mapFoldl :: (b -> a -> b) -> b -> map a -> b
mapFoldr :: (a -> b -> b) -> b -> map a -> b
mapFoldlWithKey :: (b -> KeyOf map -> a -> b) -> b -> map a -> b
mapFoldMapWithKey :: Monoid m => (KeyOf map -> a -> m) -> map a -> m
mapFilter :: (a -> Bool) -> map a -> map a
mapFilterWithKey :: (KeyOf map -> a -> Bool) -> map a -> map a
mapElems :: map a -> [a]
mapKeys :: map a -> [KeyOf map]
mapToList :: map a -> [(KeyOf map, a)]
mapFromList :: [(KeyOf map, a)] -> map a
mapFromListWith :: (a -> a -> a) -> [(KeyOf map,a)] -> map a
mapInsertList :: IsMap map => [(KeyOf map, a)] -> map a -> map a
mapInsertList :: forall (map :: * -> *) a.
IsMap map =>
[(KeyOf map, a)] -> map a -> map a
mapInsertList [(KeyOf map, a)]
assocs map a
map = (map a -> (KeyOf map, a) -> map a)
-> map a -> [(KeyOf map, a)] -> map a
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (((KeyOf map, a) -> map a -> map a)
-> map a -> (KeyOf map, a) -> map a
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((KeyOf map -> a -> map a -> map a)
-> (KeyOf map, a) -> map a -> map a
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry KeyOf map -> a -> map a -> map a
forall a. KeyOf map -> a -> map a -> map a
forall (map :: * -> *) a.
IsMap map =>
KeyOf map -> a -> map a -> map a
mapInsert)) map a
map [(KeyOf map, a)]
assocs
mapDeleteList :: IsMap map => [KeyOf map] -> map a -> map a
mapDeleteList :: forall (map :: * -> *) a.
IsMap map =>
[KeyOf map] -> map a -> map a
mapDeleteList [KeyOf map]
keys map a
map = (map a -> KeyOf map -> map a) -> map a -> [KeyOf map] -> map a
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ((KeyOf map -> map a -> map a) -> map a -> KeyOf map -> map a
forall a b c. (a -> b -> c) -> b -> a -> c
flip KeyOf map -> map a -> map a
forall a. KeyOf map -> map a -> map a
forall (map :: * -> *) a. IsMap map => KeyOf map -> map a -> map a
mapDelete) map a
map [KeyOf map]
keys
mapUnions :: IsMap map => [map a] -> map a
mapUnions :: forall (map :: * -> *) a. IsMap map => [map a] -> map a
mapUnions [] = map a
forall a. map a
forall (map :: * -> *) a. IsMap map => map a
mapEmpty
mapUnions [map a]
maps = (map a -> map a -> map a) -> [map a] -> map a
forall a. HasCallStack => (a -> a -> a) -> [a] -> a
foldl1' map a -> map a -> map a
forall a. map a -> map a -> map a
forall (map :: * -> *) a. IsMap map => map a -> map a -> map a
mapUnion [map a]
maps
newtype UniqueSet = US S.Word64Set deriving (UniqueSet -> UniqueSet -> Bool
(UniqueSet -> UniqueSet -> Bool)
-> (UniqueSet -> UniqueSet -> Bool) -> Eq UniqueSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UniqueSet -> UniqueSet -> Bool
== :: UniqueSet -> UniqueSet -> Bool
$c/= :: UniqueSet -> UniqueSet -> Bool
/= :: UniqueSet -> UniqueSet -> Bool
Eq, Eq UniqueSet
Eq UniqueSet =>
(UniqueSet -> UniqueSet -> Ordering)
-> (UniqueSet -> UniqueSet -> Bool)
-> (UniqueSet -> UniqueSet -> Bool)
-> (UniqueSet -> UniqueSet -> Bool)
-> (UniqueSet -> UniqueSet -> Bool)
-> (UniqueSet -> UniqueSet -> UniqueSet)
-> (UniqueSet -> UniqueSet -> UniqueSet)
-> Ord UniqueSet
UniqueSet -> UniqueSet -> Bool
UniqueSet -> UniqueSet -> Ordering
UniqueSet -> UniqueSet -> UniqueSet
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UniqueSet -> UniqueSet -> Ordering
compare :: UniqueSet -> UniqueSet -> Ordering
$c< :: UniqueSet -> UniqueSet -> Bool
< :: UniqueSet -> UniqueSet -> Bool
$c<= :: UniqueSet -> UniqueSet -> Bool
<= :: UniqueSet -> UniqueSet -> Bool
$c> :: UniqueSet -> UniqueSet -> Bool
> :: UniqueSet -> UniqueSet -> Bool
$c>= :: UniqueSet -> UniqueSet -> Bool
>= :: UniqueSet -> UniqueSet -> Bool
$cmax :: UniqueSet -> UniqueSet -> UniqueSet
max :: UniqueSet -> UniqueSet -> UniqueSet
$cmin :: UniqueSet -> UniqueSet -> UniqueSet
min :: UniqueSet -> UniqueSet -> UniqueSet
Ord, Int -> UniqueSet -> ShowS
[UniqueSet] -> ShowS
UniqueSet -> String
(Int -> UniqueSet -> ShowS)
-> (UniqueSet -> String)
-> ([UniqueSet] -> ShowS)
-> Show UniqueSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UniqueSet -> ShowS
showsPrec :: Int -> UniqueSet -> ShowS
$cshow :: UniqueSet -> String
show :: UniqueSet -> String
$cshowList :: [UniqueSet] -> ShowS
showList :: [UniqueSet] -> ShowS
Show, NonEmpty UniqueSet -> UniqueSet
UniqueSet -> UniqueSet -> UniqueSet
(UniqueSet -> UniqueSet -> UniqueSet)
-> (NonEmpty UniqueSet -> UniqueSet)
-> (forall b. Integral b => b -> UniqueSet -> UniqueSet)
-> Semigroup UniqueSet
forall b. Integral b => b -> UniqueSet -> UniqueSet
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: UniqueSet -> UniqueSet -> UniqueSet
<> :: UniqueSet -> UniqueSet -> UniqueSet
$csconcat :: NonEmpty UniqueSet -> UniqueSet
sconcat :: NonEmpty UniqueSet -> UniqueSet
$cstimes :: forall b. Integral b => b -> UniqueSet -> UniqueSet
stimes :: forall b. Integral b => b -> UniqueSet -> UniqueSet
Semigroup, Semigroup UniqueSet
UniqueSet
Semigroup UniqueSet =>
UniqueSet
-> (UniqueSet -> UniqueSet -> UniqueSet)
-> ([UniqueSet] -> UniqueSet)
-> Monoid UniqueSet
[UniqueSet] -> UniqueSet
UniqueSet -> UniqueSet -> UniqueSet
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: UniqueSet
mempty :: UniqueSet
$cmappend :: UniqueSet -> UniqueSet -> UniqueSet
mappend :: UniqueSet -> UniqueSet -> UniqueSet
$cmconcat :: [UniqueSet] -> UniqueSet
mconcat :: [UniqueSet] -> UniqueSet
Monoid)
instance IsSet UniqueSet where
type ElemOf UniqueSet = Word64
setNull :: UniqueSet -> Bool
setNull (US Word64Set
s) = Word64Set -> Bool
S.null Word64Set
s
setSize :: UniqueSet -> Int
setSize (US Word64Set
s) = Word64Set -> Int
S.size Word64Set
s
setMember :: ElemOf UniqueSet -> UniqueSet -> Bool
setMember ElemOf UniqueSet
k (US Word64Set
s) = Key -> Word64Set -> Bool
S.member Key
ElemOf UniqueSet
k Word64Set
s
setEmpty :: UniqueSet
setEmpty = Word64Set -> UniqueSet
US Word64Set
S.empty
setSingleton :: ElemOf UniqueSet -> UniqueSet
setSingleton ElemOf UniqueSet
k = Word64Set -> UniqueSet
US (Key -> Word64Set
S.singleton Key
ElemOf UniqueSet
k)
setInsert :: ElemOf UniqueSet -> UniqueSet -> UniqueSet
setInsert ElemOf UniqueSet
k (US Word64Set
s) = Word64Set -> UniqueSet
US (Key -> Word64Set -> Word64Set
S.insert Key
ElemOf UniqueSet
k Word64Set
s)
setDelete :: ElemOf UniqueSet -> UniqueSet -> UniqueSet
setDelete ElemOf UniqueSet
k (US Word64Set
s) = Word64Set -> UniqueSet
US (Key -> Word64Set -> Word64Set
S.delete Key
ElemOf UniqueSet
k Word64Set
s)
setUnion :: UniqueSet -> UniqueSet -> UniqueSet
setUnion (US Word64Set
x) (US Word64Set
y) = Word64Set -> UniqueSet
US (Word64Set -> Word64Set -> Word64Set
S.union Word64Set
x Word64Set
y)
setDifference :: UniqueSet -> UniqueSet -> UniqueSet
setDifference (US Word64Set
x) (US Word64Set
y) = Word64Set -> UniqueSet
US (Word64Set -> Word64Set -> Word64Set
S.difference Word64Set
x Word64Set
y)
setIntersection :: UniqueSet -> UniqueSet -> UniqueSet
setIntersection (US Word64Set
x) (US Word64Set
y) = Word64Set -> UniqueSet
US (Word64Set -> Word64Set -> Word64Set
S.intersection Word64Set
x Word64Set
y)
setIsSubsetOf :: UniqueSet -> UniqueSet -> Bool
setIsSubsetOf (US Word64Set
x) (US Word64Set
y) = Word64Set -> Word64Set -> Bool
S.isSubsetOf Word64Set
x Word64Set
y
setFilter :: (ElemOf UniqueSet -> Bool) -> UniqueSet -> UniqueSet
setFilter ElemOf UniqueSet -> Bool
f (US Word64Set
s) = Word64Set -> UniqueSet
US ((Key -> Bool) -> Word64Set -> Word64Set
S.filter Key -> Bool
ElemOf UniqueSet -> Bool
f Word64Set
s)
setFoldl :: forall b. (b -> ElemOf UniqueSet -> b) -> b -> UniqueSet -> b
setFoldl b -> ElemOf UniqueSet -> b
k b
z (US Word64Set
s) = (b -> Key -> b) -> b -> Word64Set -> b
forall a. (a -> Key -> a) -> a -> Word64Set -> a
S.foldl' b -> Key -> b
b -> ElemOf UniqueSet -> b
k b
z Word64Set
s
setFoldr :: forall b. (ElemOf UniqueSet -> b -> b) -> b -> UniqueSet -> b
setFoldr ElemOf UniqueSet -> b -> b
k b
z (US Word64Set
s) = (Key -> b -> b) -> b -> Word64Set -> b
forall b. (Key -> b -> b) -> b -> Word64Set -> b
S.foldr Key -> b -> b
ElemOf UniqueSet -> b -> b
k b
z Word64Set
s
setElems :: UniqueSet -> [ElemOf UniqueSet]
setElems (US Word64Set
s) = Word64Set -> [Key]
S.elems Word64Set
s
setFromList :: [ElemOf UniqueSet] -> UniqueSet
setFromList [ElemOf UniqueSet]
ks = Word64Set -> UniqueSet
US ([Key] -> Word64Set
S.fromList [Key]
[ElemOf UniqueSet]
ks)
newtype UniqueMap v = UM (M.Word64Map v)
deriving (UniqueMap v -> UniqueMap v -> Bool
(UniqueMap v -> UniqueMap v -> Bool)
-> (UniqueMap v -> UniqueMap v -> Bool) -> Eq (UniqueMap v)
forall v. Eq v => UniqueMap v -> UniqueMap v -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall v. Eq v => UniqueMap v -> UniqueMap v -> Bool
== :: UniqueMap v -> UniqueMap v -> Bool
$c/= :: forall v. Eq v => UniqueMap v -> UniqueMap v -> Bool
/= :: UniqueMap v -> UniqueMap v -> Bool
Eq, Eq (UniqueMap v)
Eq (UniqueMap v) =>
(UniqueMap v -> UniqueMap v -> Ordering)
-> (UniqueMap v -> UniqueMap v -> Bool)
-> (UniqueMap v -> UniqueMap v -> Bool)
-> (UniqueMap v -> UniqueMap v -> Bool)
-> (UniqueMap v -> UniqueMap v -> Bool)
-> (UniqueMap v -> UniqueMap v -> UniqueMap v)
-> (UniqueMap v -> UniqueMap v -> UniqueMap v)
-> Ord (UniqueMap v)
UniqueMap v -> UniqueMap v -> Bool
UniqueMap v -> UniqueMap v -> Ordering
UniqueMap v -> UniqueMap v -> UniqueMap v
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall v. Ord v => Eq (UniqueMap v)
forall v. Ord v => UniqueMap v -> UniqueMap v -> Bool
forall v. Ord v => UniqueMap v -> UniqueMap v -> Ordering
forall v. Ord v => UniqueMap v -> UniqueMap v -> UniqueMap v
$ccompare :: forall v. Ord v => UniqueMap v -> UniqueMap v -> Ordering
compare :: UniqueMap v -> UniqueMap v -> Ordering
$c< :: forall v. Ord v => UniqueMap v -> UniqueMap v -> Bool
< :: UniqueMap v -> UniqueMap v -> Bool
$c<= :: forall v. Ord v => UniqueMap v -> UniqueMap v -> Bool
<= :: UniqueMap v -> UniqueMap v -> Bool
$c> :: forall v. Ord v => UniqueMap v -> UniqueMap v -> Bool
> :: UniqueMap v -> UniqueMap v -> Bool
$c>= :: forall v. Ord v => UniqueMap v -> UniqueMap v -> Bool
>= :: UniqueMap v -> UniqueMap v -> Bool
$cmax :: forall v. Ord v => UniqueMap v -> UniqueMap v -> UniqueMap v
max :: UniqueMap v -> UniqueMap v -> UniqueMap v
$cmin :: forall v. Ord v => UniqueMap v -> UniqueMap v -> UniqueMap v
min :: UniqueMap v -> UniqueMap v -> UniqueMap v
Ord, Int -> UniqueMap v -> ShowS
[UniqueMap v] -> ShowS
UniqueMap v -> String
(Int -> UniqueMap v -> ShowS)
-> (UniqueMap v -> String)
-> ([UniqueMap v] -> ShowS)
-> Show (UniqueMap v)
forall v. Show v => Int -> UniqueMap v -> ShowS
forall v. Show v => [UniqueMap v] -> ShowS
forall v. Show v => UniqueMap v -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall v. Show v => Int -> UniqueMap v -> ShowS
showsPrec :: Int -> UniqueMap v -> ShowS
$cshow :: forall v. Show v => UniqueMap v -> String
show :: UniqueMap v -> String
$cshowList :: forall v. Show v => [UniqueMap v] -> ShowS
showList :: [UniqueMap v] -> ShowS
Show, (forall a b. (a -> b) -> UniqueMap a -> UniqueMap b)
-> (forall a b. a -> UniqueMap b -> UniqueMap a)
-> Functor UniqueMap
forall a b. a -> UniqueMap b -> UniqueMap a
forall a b. (a -> b) -> UniqueMap a -> UniqueMap b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> UniqueMap a -> UniqueMap b
fmap :: forall a b. (a -> b) -> UniqueMap a -> UniqueMap b
$c<$ :: forall a b. a -> UniqueMap b -> UniqueMap a
<$ :: forall a b. a -> UniqueMap b -> UniqueMap a
Functor, (forall m. Monoid m => UniqueMap m -> m)
-> (forall m a. Monoid m => (a -> m) -> UniqueMap a -> m)
-> (forall m a. Monoid m => (a -> m) -> UniqueMap a -> m)
-> (forall a b. (a -> b -> b) -> b -> UniqueMap a -> b)
-> (forall a b. (a -> b -> b) -> b -> UniqueMap a -> b)
-> (forall b a. (b -> a -> b) -> b -> UniqueMap a -> b)
-> (forall b a. (b -> a -> b) -> b -> UniqueMap a -> b)
-> (forall a. (a -> a -> a) -> UniqueMap a -> a)
-> (forall a. (a -> a -> a) -> UniqueMap a -> a)
-> (forall a. UniqueMap a -> [a])
-> (forall a. UniqueMap a -> Bool)
-> (forall a. UniqueMap a -> Int)
-> (forall a. Eq a => a -> UniqueMap a -> Bool)
-> (forall a. Ord a => UniqueMap a -> a)
-> (forall a. Ord a => UniqueMap a -> a)
-> (forall a. Num a => UniqueMap a -> a)
-> (forall a. Num a => UniqueMap a -> a)
-> Foldable UniqueMap
forall a. Eq a => a -> UniqueMap a -> Bool
forall a. Num a => UniqueMap a -> a
forall a. Ord a => UniqueMap a -> a
forall m. Monoid m => UniqueMap m -> m
forall a. UniqueMap a -> Bool
forall a. UniqueMap a -> Int
forall a. UniqueMap a -> [a]
forall a. (a -> a -> a) -> UniqueMap a -> a
forall m a. Monoid m => (a -> m) -> UniqueMap a -> m
forall b a. (b -> a -> b) -> b -> UniqueMap a -> b
forall a b. (a -> b -> b) -> b -> UniqueMap a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => UniqueMap m -> m
fold :: forall m. Monoid m => UniqueMap m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> UniqueMap a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> UniqueMap a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> UniqueMap a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> UniqueMap a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> UniqueMap a -> b
foldr :: forall a b. (a -> b -> b) -> b -> UniqueMap a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> UniqueMap a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> UniqueMap a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> UniqueMap a -> b
foldl :: forall b a. (b -> a -> b) -> b -> UniqueMap a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> UniqueMap a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> UniqueMap a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> UniqueMap a -> a
foldr1 :: forall a. (a -> a -> a) -> UniqueMap a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> UniqueMap a -> a
foldl1 :: forall a. (a -> a -> a) -> UniqueMap a -> a
$ctoList :: forall a. UniqueMap a -> [a]
toList :: forall a. UniqueMap a -> [a]
$cnull :: forall a. UniqueMap a -> Bool
null :: forall a. UniqueMap a -> Bool
$clength :: forall a. UniqueMap a -> Int
length :: forall a. UniqueMap a -> Int
$celem :: forall a. Eq a => a -> UniqueMap a -> Bool
elem :: forall a. Eq a => a -> UniqueMap a -> Bool
$cmaximum :: forall a. Ord a => UniqueMap a -> a
maximum :: forall a. Ord a => UniqueMap a -> a
$cminimum :: forall a. Ord a => UniqueMap a -> a
minimum :: forall a. Ord a => UniqueMap a -> a
$csum :: forall a. Num a => UniqueMap a -> a
sum :: forall a. Num a => UniqueMap a -> a
$cproduct :: forall a. Num a => UniqueMap a -> a
product :: forall a. Num a => UniqueMap a -> a
Foldable, Functor UniqueMap
Foldable UniqueMap
(Functor UniqueMap, Foldable UniqueMap) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UniqueMap a -> f (UniqueMap b))
-> (forall (f :: * -> *) a.
Applicative f =>
UniqueMap (f a) -> f (UniqueMap a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UniqueMap a -> m (UniqueMap b))
-> (forall (m :: * -> *) a.
Monad m =>
UniqueMap (m a) -> m (UniqueMap a))
-> Traversable UniqueMap
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
UniqueMap (m a) -> m (UniqueMap a)
forall (f :: * -> *) a.
Applicative f =>
UniqueMap (f a) -> f (UniqueMap a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UniqueMap a -> m (UniqueMap b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UniqueMap a -> f (UniqueMap b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UniqueMap a -> f (UniqueMap b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> UniqueMap a -> f (UniqueMap b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
UniqueMap (f a) -> f (UniqueMap a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
UniqueMap (f a) -> f (UniqueMap a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UniqueMap a -> m (UniqueMap b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> UniqueMap a -> m (UniqueMap b)
$csequence :: forall (m :: * -> *) a.
Monad m =>
UniqueMap (m a) -> m (UniqueMap a)
sequence :: forall (m :: * -> *) a.
Monad m =>
UniqueMap (m a) -> m (UniqueMap a)
Traversable)
instance IsMap UniqueMap where
type KeyOf UniqueMap = Word64
mapNull :: forall a. UniqueMap a -> Bool
mapNull (UM Word64Map a
m) = Word64Map a -> Bool
forall a. Word64Map a -> Bool
M.null Word64Map a
m
mapSize :: forall a. UniqueMap a -> Int
mapSize (UM Word64Map a
m) = Word64Map a -> Int
forall a. Word64Map a -> Int
M.size Word64Map a
m
mapMember :: forall a. KeyOf UniqueMap -> UniqueMap a -> Bool
mapMember KeyOf UniqueMap
k (UM Word64Map a
m) = Key -> Word64Map a -> Bool
forall a. Key -> Word64Map a -> Bool
M.member Key
KeyOf UniqueMap
k Word64Map a
m
mapLookup :: forall a. KeyOf UniqueMap -> UniqueMap a -> Maybe a
mapLookup KeyOf UniqueMap
k (UM Word64Map a
m) = Key -> Word64Map a -> Maybe a
forall a. Key -> Word64Map a -> Maybe a
M.lookup Key
KeyOf UniqueMap
k Word64Map a
m
mapFindWithDefault :: forall a. a -> KeyOf UniqueMap -> UniqueMap a -> a
mapFindWithDefault a
def KeyOf UniqueMap
k (UM Word64Map a
m) = a -> Key -> Word64Map a -> a
forall a. a -> Key -> Word64Map a -> a
M.findWithDefault a
def Key
KeyOf UniqueMap
k Word64Map a
m
mapEmpty :: forall a. UniqueMap a
mapEmpty = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM Word64Map a
forall a. Word64Map a
M.empty
mapSingleton :: forall a. KeyOf UniqueMap -> a -> UniqueMap a
mapSingleton KeyOf UniqueMap
k a
v = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM (Key -> a -> Word64Map a
forall a. Key -> a -> Word64Map a
M.singleton Key
KeyOf UniqueMap
k a
v)
mapInsert :: forall a. KeyOf UniqueMap -> a -> UniqueMap a -> UniqueMap a
mapInsert KeyOf UniqueMap
k a
v (UM Word64Map a
m) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM (Key -> a -> Word64Map a -> Word64Map a
forall a. Key -> a -> Word64Map a -> Word64Map a
M.insert Key
KeyOf UniqueMap
k a
v Word64Map a
m)
mapInsertWith :: forall a.
(a -> a -> a) -> KeyOf UniqueMap -> a -> UniqueMap a -> UniqueMap a
mapInsertWith a -> a -> a
f KeyOf UniqueMap
k a
v (UM Word64Map a
m) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM ((a -> a -> a) -> Key -> a -> Word64Map a -> Word64Map a
forall a. (a -> a -> a) -> Key -> a -> Word64Map a -> Word64Map a
M.insertWith a -> a -> a
f Key
KeyOf UniqueMap
k a
v Word64Map a
m)
mapDelete :: forall a. KeyOf UniqueMap -> UniqueMap a -> UniqueMap a
mapDelete KeyOf UniqueMap
k (UM Word64Map a
m) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM (Key -> Word64Map a -> Word64Map a
forall a. Key -> Word64Map a -> Word64Map a
M.delete Key
KeyOf UniqueMap
k Word64Map a
m)
mapAlter :: forall a.
(Maybe a -> Maybe a)
-> KeyOf UniqueMap -> UniqueMap a -> UniqueMap a
mapAlter Maybe a -> Maybe a
f KeyOf UniqueMap
k (UM Word64Map a
m) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM ((Maybe a -> Maybe a) -> Key -> Word64Map a -> Word64Map a
forall a. (Maybe a -> Maybe a) -> Key -> Word64Map a -> Word64Map a
M.alter Maybe a -> Maybe a
f Key
KeyOf UniqueMap
k Word64Map a
m)
mapAdjust :: forall a. (a -> a) -> KeyOf UniqueMap -> UniqueMap a -> UniqueMap a
mapAdjust a -> a
f KeyOf UniqueMap
k (UM Word64Map a
m) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM ((a -> a) -> Key -> Word64Map a -> Word64Map a
forall a. (a -> a) -> Key -> Word64Map a -> Word64Map a
M.adjust a -> a
f Key
KeyOf UniqueMap
k Word64Map a
m)
mapUnion :: forall a. UniqueMap a -> UniqueMap a -> UniqueMap a
mapUnion (UM Word64Map a
x) (UM Word64Map a
y) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM (Word64Map a -> Word64Map a -> Word64Map a
forall a. Word64Map a -> Word64Map a -> Word64Map a
M.union Word64Map a
x Word64Map a
y)
mapUnionWithKey :: forall a.
(KeyOf UniqueMap -> a -> a -> a)
-> UniqueMap a -> UniqueMap a -> UniqueMap a
mapUnionWithKey KeyOf UniqueMap -> a -> a -> a
f (UM Word64Map a
x) (UM Word64Map a
y) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM ((Key -> a -> a -> a) -> Word64Map a -> Word64Map a -> Word64Map a
forall a.
(Key -> a -> a -> a) -> Word64Map a -> Word64Map a -> Word64Map a
M.unionWithKey Key -> a -> a -> a
KeyOf UniqueMap -> a -> a -> a
f Word64Map a
x Word64Map a
y)
mapDifference :: forall a. UniqueMap a -> UniqueMap a -> UniqueMap a
mapDifference (UM Word64Map a
x) (UM Word64Map a
y) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM (Word64Map a -> Word64Map a -> Word64Map a
forall a b. Word64Map a -> Word64Map b -> Word64Map a
M.difference Word64Map a
x Word64Map a
y)
mapIntersection :: forall a. UniqueMap a -> UniqueMap a -> UniqueMap a
mapIntersection (UM Word64Map a
x) (UM Word64Map a
y) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM (Word64Map a -> Word64Map a -> Word64Map a
forall a b. Word64Map a -> Word64Map b -> Word64Map a
M.intersection Word64Map a
x Word64Map a
y)
mapIsSubmapOf :: forall v. Eq v => UniqueMap v -> UniqueMap v -> Bool
mapIsSubmapOf (UM Word64Map a
x) (UM Word64Map a
y) = Word64Map a -> Word64Map a -> Bool
forall a. Eq a => Word64Map a -> Word64Map a -> Bool
M.isSubmapOf Word64Map a
x Word64Map a
y
mapMap :: forall a b. (a -> b) -> UniqueMap a -> UniqueMap b
mapMap a -> b
f (UM Word64Map a
m) = Word64Map b -> UniqueMap b
forall v. Word64Map v -> UniqueMap v
UM ((a -> b) -> Word64Map a -> Word64Map b
forall a b. (a -> b) -> Word64Map a -> Word64Map b
M.map a -> b
f Word64Map a
m)
mapMapWithKey :: forall a b.
(KeyOf UniqueMap -> a -> b) -> UniqueMap a -> UniqueMap b
mapMapWithKey KeyOf UniqueMap -> a -> b
f (UM Word64Map a
m) = Word64Map b -> UniqueMap b
forall v. Word64Map v -> UniqueMap v
UM ((Key -> a -> b) -> Word64Map a -> Word64Map b
forall a b. (Key -> a -> b) -> Word64Map a -> Word64Map b
M.mapWithKey Key -> a -> b
KeyOf UniqueMap -> a -> b
f Word64Map a
m)
mapFoldl :: forall b a. (b -> a -> b) -> b -> UniqueMap a -> b
mapFoldl b -> a -> b
k b
z (UM Word64Map a
m) = (b -> a -> b) -> b -> Word64Map a -> b
forall a b. (a -> b -> a) -> a -> Word64Map b -> a
M.foldl' b -> a -> b
k b
z Word64Map a
m
mapFoldr :: forall a b. (a -> b -> b) -> b -> UniqueMap a -> b
mapFoldr a -> b -> b
k b
z (UM Word64Map a
m) = (a -> b -> b) -> b -> Word64Map a -> b
forall a b. (a -> b -> b) -> b -> Word64Map a -> b
M.foldr a -> b -> b
k b
z Word64Map a
m
mapFoldlWithKey :: forall b a.
(b -> KeyOf UniqueMap -> a -> b) -> b -> UniqueMap a -> b
mapFoldlWithKey b -> KeyOf UniqueMap -> a -> b
k b
z (UM Word64Map a
m) = (b -> Key -> a -> b) -> b -> Word64Map a -> b
forall a b. (a -> Key -> b -> a) -> a -> Word64Map b -> a
M.foldlWithKey' b -> Key -> a -> b
b -> KeyOf UniqueMap -> a -> b
k b
z Word64Map a
m
mapFoldMapWithKey :: forall m a.
Monoid m =>
(KeyOf UniqueMap -> a -> m) -> UniqueMap a -> m
mapFoldMapWithKey KeyOf UniqueMap -> a -> m
f (UM Word64Map a
m) = (Key -> a -> m) -> Word64Map a -> m
forall m a. Monoid m => (Key -> a -> m) -> Word64Map a -> m
M.foldMapWithKey Key -> a -> m
KeyOf UniqueMap -> a -> m
f Word64Map a
m
{-# INLINEABLE mapFilter #-}
mapFilter :: forall a. (a -> Bool) -> UniqueMap a -> UniqueMap a
mapFilter a -> Bool
f (UM Word64Map a
m) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM ((a -> Bool) -> Word64Map a -> Word64Map a
forall a. (a -> Bool) -> Word64Map a -> Word64Map a
M.filter a -> Bool
f Word64Map a
m)
{-# INLINEABLE mapFilterWithKey #-}
mapFilterWithKey :: forall a.
(KeyOf UniqueMap -> a -> Bool) -> UniqueMap a -> UniqueMap a
mapFilterWithKey KeyOf UniqueMap -> a -> Bool
f (UM Word64Map a
m) = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM ((Key -> a -> Bool) -> Word64Map a -> Word64Map a
forall a. (Key -> a -> Bool) -> Word64Map a -> Word64Map a
M.filterWithKey Key -> a -> Bool
KeyOf UniqueMap -> a -> Bool
f Word64Map a
m)
mapElems :: forall a. UniqueMap a -> [a]
mapElems (UM Word64Map a
m) = Word64Map a -> [a]
forall a. Word64Map a -> [a]
M.elems Word64Map a
m
mapKeys :: forall a. UniqueMap a -> [KeyOf UniqueMap]
mapKeys (UM Word64Map a
m) = Word64Map a -> [Key]
forall a. Word64Map a -> [Key]
M.keys Word64Map a
m
{-# INLINEABLE mapToList #-}
mapToList :: forall a. UniqueMap a -> [(KeyOf UniqueMap, a)]
mapToList (UM Word64Map a
m) = Word64Map a -> [(Key, a)]
forall a. Word64Map a -> [(Key, a)]
M.toList Word64Map a
m
mapFromList :: forall a. [(KeyOf UniqueMap, a)] -> UniqueMap a
mapFromList [(KeyOf UniqueMap, a)]
assocs = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM ([(Key, a)] -> Word64Map a
forall a. [(Key, a)] -> Word64Map a
M.fromList [(Key, a)]
[(KeyOf UniqueMap, a)]
assocs)
mapFromListWith :: forall a. (a -> a -> a) -> [(KeyOf UniqueMap, a)] -> UniqueMap a
mapFromListWith a -> a -> a
f [(KeyOf UniqueMap, a)]
assocs = Word64Map a -> UniqueMap a
forall v. Word64Map v -> UniqueMap v
UM ((a -> a -> a) -> [(Key, a)] -> Word64Map a
forall a. (a -> a -> a) -> [(Key, a)] -> Word64Map a
M.fromListWith a -> a -> a
f [(Key, a)]
[(KeyOf UniqueMap, a)]
assocs)