Agda
Safe HaskellNone
LanguageHaskell2010

Agda.Utils.Map

Synopsis

Monadic map operations

insertWithGood :: forall k a c. Ord k => (c -> a -> a -> a) -> c -> k -> a -> Map k a -> Map k a Source #

Version of insertWith that's willing to be properly inlined. The extra c argument is passed down to the insertions unchanged. It can be used to avoid closure creation for the loop.

forGood_ :: forall k v m. Applicative m => Map k v -> (v -> m ()) -> m () Source #

Version of forM_ that deigns to be properly lambda-lifted for State, Reader, etc.

forWithKey_ :: forall k v m. Applicative m => Map k v -> (k -> v -> m ()) -> m () Source #

adjustM :: (Functor f, Ord k) => (v -> f v) -> k -> Map k v -> f (Map k v) Source #

Update monadically the value at one position (must exist!).

adjustM' :: (Functor f, Ord k) => (v -> f (a, v)) -> k -> Map k v -> f (a, Map k v) Source #

Wrapper for adjustM for convenience.

Non-monadic map operations

mapKeysMaybe :: Ord k => (k -> Maybe k) -> Map k a -> Map k a Source #

Filter a map and rewrite the keys.

isSingleMap :: Map k v -> Maybe (k, v) Source #

Check whether a map is a singleton.

partitionKeys :: Ord k => Map k a -> Set k -> (Map k a, Map k a) Source #

partitionKeys m s = partition (member s) m but with potential for efficient implementation.

partitionMap :: Ord k => Map k a -> Map k b -> (Map k a, Map k a) Source #

partitionMap m m' = partition (member m') m but with potential for efficient implementation.