Module

Data.StrMap

Package
purescript-maps
Repository
purescript/purescript-maps

This module defines a type of native Javascript maps which require the keys to be strings.

To maximize performance, Javascript objects are not wrapped, and some native code is used even when it's not necessary.

#StrMap Source

#thawST Source

thawST :: forall a h r. StrMap a -> Eff (st :: ST h | r) (STStrMap h a)

Convert an immutable map into a mutable map

#freezeST Source

freezeST :: forall a h r. STStrMap h a -> Eff (st :: ST h | r) (StrMap a)

Convert a mutable map into an immutable map

#runST Source

runST :: forall a r. (forall h. Eff (st :: ST h | r) (STStrMap h a)) -> Eff r (StrMap a)

Freeze a mutable map, creating an immutable map. Use this function as you would use Prelude.runST to freeze a mutable reference.

The rank-2 type prevents the map from escaping the scope of runST.

#pureST Source

pureST :: forall a. (forall h e. Eff (st :: ST h | e) (STStrMap h a)) -> StrMap a

#fold Source

fold :: forall a z. (z -> String -> a -> z) -> z -> StrMap a -> z

Fold the keys and values of a map

#foldMap Source

foldMap :: forall a m. Monoid m => (String -> a -> m) -> StrMap a -> m

Fold the keys and values of a map, accumulating values using some Monoid.

#foldM Source

foldM :: forall a m z. Monad m => (z -> String -> a -> m z) -> z -> StrMap a -> m z

Fold the keys and values of a map, accumulating values and effects in some Monad.

#foldMaybe Source

foldMaybe :: forall a z. (z -> String -> a -> Maybe z) -> z -> StrMap a -> z

Fold the keys and values of a map.

This function allows the folding function to terminate the fold early, using Maybe.

#all Source

all :: forall a. (String -> a -> Boolean) -> StrMap a -> Boolean

Test whether all key/value pairs in a StrMap satisfy a predicate.

#empty Source

empty :: forall a. StrMap a

An empty map

#isSubmap Source

isSubmap :: forall a. Eq a => StrMap a -> StrMap a -> Boolean

Test whether one map contains all of the keys and values contained in another map

#isEmpty Source

isEmpty :: forall a. StrMap a -> Boolean

Test whether a map is empty

#size Source

size :: forall a. StrMap a -> Int

Calculate the number of key/value pairs in a map

#singleton Source

singleton :: forall a. String -> a -> StrMap a

Create a map with one key/value pair

#lookup Source

lookup :: forall a. String -> StrMap a -> Maybe a

Lookup the value for a key in a map

#member Source

member :: forall a. String -> StrMap a -> Boolean

Test whether a String appears as a key in a map

#insert Source

insert :: forall a. String -> a -> StrMap a -> StrMap a

Insert or replace a key/value pair in a map

#delete Source

delete :: forall a. String -> StrMap a -> StrMap a

Delete a key and value from a map

#pop Source

pop :: forall a. String -> StrMap a -> Maybe (Tuple a (StrMap a))

Delete a key and value from a map, returning the value as well as the subsequent map

#alter Source

alter :: forall a. (Maybe a -> Maybe a) -> String -> StrMap a -> StrMap a

Insert, remove or update a value for a key in a map

#update Source

update :: forall a. (a -> Maybe a) -> String -> StrMap a -> StrMap a

Remove or update a value for a key in a map

#fromFoldable Source

fromFoldable :: forall f a. Foldable f => f (Tuple String a) -> StrMap a

Create a map from a foldable collection of key/value pairs

#fromFoldableWith Source

fromFoldableWith :: forall f a. Foldable f => (a -> a -> a) -> f (Tuple String a) -> StrMap a

Create a map from a foldable collection of key/value pairs, using the specified function to combine values for duplicate keys.

#toArrayWithKey Source

toArrayWithKey :: forall a b. (String -> a -> b) -> StrMap a -> Array b

#toUnfoldable Source

toUnfoldable :: forall f a. Unfoldable f => StrMap a -> f (Tuple String a)

Unfolds a map into a list of key/value pairs

#toAscUnfoldable Source

toAscUnfoldable :: forall f a. Unfoldable f => StrMap a -> f (Tuple String a)

Unfolds a map into a list of key/value pairs which is guaranteed to be sorted by key

#keys Source

keys :: forall a. StrMap a -> Array String

Get an array of the keys in a map

#values Source

values :: forall a. StrMap a -> Array a

Get a list of the values in a map

#union Source

union :: forall a. StrMap a -> StrMap a -> StrMap a

Compute the union of two maps, preferring the first map in the case of duplicate keys.

#unions Source

unions :: forall f a. Foldable f => f (StrMap a) -> StrMap a

Compute the union of a collection of maps

#mapWithKey Source

mapWithKey :: forall a b. (String -> a -> b) -> StrMap a -> StrMap b

Apply a function of two arguments to each key/value pair, producing a new map

#filterWithKey Source

filterWithKey :: forall a. (String -> a -> Boolean) -> StrMap a -> StrMap a

Filter out those key/value pairs of a map for which a predicate fails to hold.

#filterKeys Source

filterKeys :: (String -> Boolean) -> StrMap ~> StrMap

Filter out those key/value pairs of a map for which a predicate on the key fails to hold.

#filter Source

filter :: forall a. (a -> Boolean) -> StrMap a -> StrMap a

Filter out those key/value pairs of a map for which a predicate on the value fails to hold.