graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Data.HashMap.Strict.Extended

Synopsis

Documentation

fromListOn :: (Eq k, Hashable k) => (v -> k) -> [v] -> HashMap k v Source #

groupOn :: (Eq k, Hashable k, Foldable t) => (v -> k) -> t v -> HashMap k [v] Source #

Given a Foldable sequence of values and a function that extracts a key from each value, returns a HashMap that maps each key to a list of all values in the sequence for which the given function produced it.

>>> groupOn (take 1) ["foo", "bar", "baz"]
fromList [("f", ["foo"]), ("b", ["bar", "baz"])]

groupOnNE :: (Eq k, Hashable k, Foldable t) => (v -> k) -> t v -> HashMap k (NonEmpty v) Source #

differenceOn :: (Eq k, Hashable k, Foldable t) => (v -> k) -> t v -> t v -> HashMap k v Source #

insertWithM :: (Monad m, Hashable k, Eq k) => (v -> v -> m v) -> k -> v -> HashMap k v -> m (HashMap k v) Source #

isInverseOf :: (Eq k, Hashable k, Eq v, Hashable v) => HashMap k v -> HashMap v k -> Bool Source #

Determines whether the left-hand-side and the right-hand-side are inverses of each other.

More specifically, for two maps A and B, isInverseOf is satisfied when both of the following are true: 1. ∀ key ∈ A. A[key] ∈ B ∧ B[A[key]] == key 2. ∀ key ∈ B. B[key] ∈ A ∧ A[B[key]] == key

unionWithM :: (Monad m, Eq k, Hashable k) => (k -> v -> v -> m v) -> HashMap k v -> HashMap k v -> m (HashMap k v) Source #

The union of two maps.

If a key occurs in both maps, the provided function (first argument) will be used to compute the result. Unlike unionWith, unionWithM performs the computation in an arbitratry monad.

unionsAll :: (Eq k, Hashable k, Foldable t) => t (HashMap k v) -> HashMap k (NonEmpty v) Source #

Like unions, but keeping all elements in the result.

homogenise :: (Hashable a, Eq a) => b -> [HashMap a b] -> (HashSet a, [HashMap a b]) Source #

Homogenise maps, such that all maps range over the full set of keys, inserting a default value as needed.