Module

JS.Map.Primitive.Internal

Package
purescript-js-maps
Repository
gbagan/purescript-js-maps

#Map Source

data Map t0 t1

Instances

#STMap Source

data STMap :: Region -> Type -> Type -> Typedata STMap t0 t1 t2

A reference to a mutable Map

The first type parameter represents the memory region which the map belongs to. The second type parameter defines the type of elements of the mutable map.

The runtime representation of a value of type STMap r k v is the same as that of Map k v, except that mutation is allowed.

#_copyST Source

_copyST :: forall a b r. a -> ST r b

#thaw Source

thaw :: forall r k v. Map k v -> ST r (STMap r k v)

Convert an immutable Map into a mutable Map

#freeze Source

freeze :: forall r k v. STMap r k v -> ST r (Map k v)

Convert a mutable Map into an immutable Map

#run Source

run :: forall k v. (forall r. ST r (STMap r k v)) -> Map k v

Freeze a mutable Map, creating an immutable Map. Use this function as you would use Control.Monad.ST.run (from the purescript-st package) to freeze a mutable reference.

The rank-2 type prevents the Map from escaping the scope of run.

#mutate Source

mutate :: forall a k v. Key k => (forall r. STMap r k v -> ST r a) -> Map k v -> Map k v

#_fmapMap Source

_fmapMap :: forall k v v'. Fn2 (Map k v) (v -> v') (Map k v')

#_foldM Source

_foldM :: forall k v m z. (m -> (z -> m) -> m) -> (z -> k -> v -> m) -> m -> Map k v -> m

#fold Source

fold :: forall k v z. Key k => (z -> k -> v -> z) -> z -> Map k v -> z

Fold the keys and values of an object

#foldMap Source

foldMap :: forall k v m. Key k => Monoid m => (k -> v -> m) -> Map k v -> m

Fold the keys and values of an object, accumulating values using some Monoid.

#foldM Source

foldM :: forall k v m z. Key k => Monad m => (z -> k -> v -> m z) -> z -> Map k v -> m z

Fold the keys and values of an object, accumulating values and effects in some Monad.

#_foldSCMap Source

_foldSCMap :: forall k v z. Fn4 (Map k v) z (z -> k -> v -> Maybe z) (forall b. b -> Maybe b -> b) z

#foldMaybe Source

foldMaybe :: forall k v z. Key k => (z -> k -> v -> Maybe z) -> z -> Map k v -> 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 k v. Key k => (k -> v -> Boolean) -> Map k v -> Boolean

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

#_all Source

_all :: forall k v. (k -> v -> Boolean) -> Map k v -> Boolean

#toAscArray Source

toAscArray :: forall k v. Key k => Map k v -> Array (Tuple k v)

#empty Source

empty :: forall k v. Map k v

An empty map

#isSubmap Source

isSubmap :: forall k v. Key k => Eq v => Map k v -> Map k v -> Boolean

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

#isEmpty Source

isEmpty :: forall k v. Key k => Map k v -> Boolean

Test whether a map is empty

#size Source

size :: forall k v. Map k v -> Int

Calculate the number of key/value pairs in a map

#singleton Source

singleton :: forall k v. Key k => k -> v -> Map k v

Create an Map a with one key/value pair

#_lookup Source

_lookup :: forall k v z. Fn4 z (v -> z) k (Map k v) z

#lookup Source

lookup :: forall k v. Key k => k -> Map k v -> Maybe v

Lookup the value for a key in a map

#member Source

member :: forall k v. Key k => k -> Map k v -> Boolean

Test whether a key appears in a map

#insert Source

insert :: forall k v. Key k => k -> v -> Map k v -> Map k v

Insert or replace a key/value pair in a map

#delete Source

delete :: forall k v. Key k => k -> Map k v -> Map k v

Delete a key and value from a map

#pop Source

pop :: forall k v. Key k => k -> Map k v -> Maybe (Tuple v (Map k v))

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

#alter Source

alter :: forall k v. Key k => (Maybe v -> Maybe v) -> k -> Map k v -> Map k v

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

#update Source

update :: forall k v. Key k => (v -> Maybe v) -> k -> Map k v -> Map k v

Remove or update a value for a key in a map

#fromFoldable Source

fromFoldable :: forall f k v. Key k => Foldable f => f (Tuple k v) -> Map k v

Create an Map k v from a foldable collection of key/value pairs

#fromFoldableWithIndex Source

fromFoldableWithIndex :: forall f k v. Key k => FoldableWithIndex k (f k) => f k v -> Map k v

Create an Map k v from a k-indexed foldable collection

#_lookupST Source

_lookupST :: forall k v r z. STFn4 z (v -> z) k (STMap r k v) r z

#fromFoldableWith Source

fromFoldableWith :: forall f k v. Key k => Foldable f => (v -> v -> v) -> f (Tuple k v) -> Map k v

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

#toArrayWithKey Source

toArrayWithKey :: forall k v a. (k -> v -> a) -> Map k v -> Array a

#toUnfoldable Source

toUnfoldable :: forall f k v. Key k => Unfoldable f => Map k v -> f (Tuple k v)

Unfolds a map into a list of key/value pairs

#toAscUnfoldable Source

toAscUnfoldable :: forall f k v. Key k => Unfoldable f => Map k v -> f (Tuple k v)

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

#toArray Source

toArray :: forall k v. Key k => Map k v -> Array (Tuple k v)

#keys Source

keys :: forall k v. Map k v -> Array k

Get an array of the keys in a map

#values Source

values :: forall k v. Map k v -> Array v

Get a list of the values in a map

#union Source

union :: forall k v. Key k => Map k v -> Map k v -> Map k v

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

#unionWith Source

unionWith :: forall k v. Key k => (v -> v -> v) -> Map k v -> Map k v -> Map k v

Compute the union of two maps, using the specified function to combine values for duplicate keys.

#unions Source

unions :: forall f k v. Key k => Foldable f => f (Map k v) -> Map k v

Compute the union of a collection of maps

#_mapWithKey Source

_mapWithKey :: forall k v v'. Fn2 (Map k v) (k -> v -> v') (Map k v')

#mapWithKey Source

mapWithKey :: forall k v v'. Key k => (k -> v -> v') -> Map k v -> Map k v'

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

#filterWithKey Source

filterWithKey :: forall k v. Key k => (k -> v -> Boolean) -> Map k v -> Map k v

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

#filterKeys Source

filterKeys :: forall k. Key k => (k -> Boolean) -> (Map k) ~> (Map k)

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

#filter Source

filter :: forall k v. Key k => (v -> Boolean) -> Map k v -> Map k v

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

#new Source

new :: forall r k v. ST r (STMap r k v)

Create a new, empty mutable map

#peek Source

peek :: forall r k v. Key k => k -> STMap r k v -> ST r (Maybe v)

Get the value for a key in a mutable map

#peekImpl Source

peekImpl :: forall r m k v. STFn4 m k (v -> Maybe v) (Maybe v) r v

#poke Source

poke :: forall r k v. Key k => k -> v -> STMap r k v -> ST r (STMap r k v)

Update the value for a key in a mutable map

#poke_ Source

poke_ :: forall r k v. Key k => k -> v -> STMap r k v -> ST r Unit

#pokeImpl Source

pokeImpl :: forall r k v m. STFn3 m k v r Unit

#deleteST Source

deleteST :: forall r k v. Key k => k -> STMap r k v -> ST r (STMap r k v)

#delete_ Source

delete_ :: forall r k v. Key k => k -> STMap r k v -> ST r Unit

Remove a key and the corresponding value from a mutable map

#deleteImpl Source

deleteImpl :: forall r k m. STFn2 m k r Unit