Module

Data.StrMap

Package
purescript-mapsDEPRECATED
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

data StrMap :: Type -> Type

StrMap a represents a map from Strings to values of type a.

Instances

#thawST Source

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

Convert an immutable map into a mutable map

#freezeST Source

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

Convert a mutable map into an immutable map

#runST Source

runST :: forall r a. (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 e h. Eff (st :: ST h | e) (STStrMap h a)) -> StrMap a

#fold Source

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

Fold the keys and values of a map

#foldMap Source

foldMap :: forall m a. 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 z m a. 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 z a. (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 a f. Foldable f => f (Tuple String a) -> StrMap a

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

#fromFoldableWith Source

fromFoldableWith :: forall a f. 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.

#toUnfoldable Source

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

Unfolds a map into a list of key/value pairs

#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 a f. Foldable f => f (StrMap a) -> StrMap a

Compute the union of a collection of maps

#mapWithKey Source

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

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