module GHC.Data.FiniteMap (
insertList,
insertListWith,
deleteList,
foldRight, foldRightWithKey
) where
import GHC.Prelude
import Data.Map (Map)
import qualified Data.Map as Map
insertList :: Ord key => [(key,elt)] -> Map key elt -> Map key elt
insertList :: forall key elt.
Ord key =>
[(key, elt)] -> Map key elt -> Map key elt
insertList [(key, elt)]
xs Map key elt
m = (Map key elt -> (key, elt) -> Map key elt)
-> Map key elt -> [(key, elt)] -> Map key elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\Map key elt
m (key
k, elt
v) -> key -> elt -> Map key elt -> Map key elt
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert key
k elt
v Map key elt
m) Map key elt
m [(key, elt)]
xs
insertListWith :: Ord key
=> (elt -> elt -> elt)
-> [(key,elt)]
-> Map key elt
-> Map key elt
insertListWith :: forall key elt.
Ord key =>
(elt -> elt -> elt) -> [(key, elt)] -> Map key elt -> Map key elt
insertListWith elt -> elt -> elt
f [(key, elt)]
xs Map key elt
m0 = (Map key elt -> (key, elt) -> Map key elt)
-> Map key elt -> [(key, elt)] -> Map key elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\Map key elt
m (key
k, elt
v) -> (elt -> elt -> elt) -> key -> elt -> Map key elt -> Map key elt
forall k a. Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
Map.insertWith elt -> elt -> elt
f key
k elt
v Map key elt
m) Map key elt
m0 [(key, elt)]
xs
deleteList :: Ord key => [key] -> Map key elt -> Map key elt
deleteList :: forall key elt. Ord key => [key] -> Map key elt -> Map key elt
deleteList [key]
ks Map key elt
m = (Map key elt -> key -> Map key elt)
-> Map key elt -> [key] -> Map key elt
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ((key -> Map key elt -> Map key elt)
-> Map key elt -> key -> Map key elt
forall a b c. (a -> b -> c) -> b -> a -> c
flip key -> Map key elt -> Map key elt
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete) Map key elt
m [key]
ks
foldRight :: (elt -> a -> a) -> a -> Map key elt -> a
foldRight :: forall elt a key. (elt -> a -> a) -> a -> Map key elt -> a
foldRight = (elt -> a -> a) -> a -> Map key elt -> a
forall elt a key. (elt -> a -> a) -> a -> Map key elt -> a
Map.foldr
foldRightWithKey :: (key -> elt -> a -> a) -> a -> Map key elt -> a
foldRightWithKey :: forall key elt a. (key -> elt -> a -> a) -> a -> Map key elt -> a
foldRightWithKey = (key -> elt -> a -> a) -> a -> Map key elt -> a
forall key elt a. (key -> elt -> a -> a) -> a -> Map key elt -> a
Map.foldrWithKey