Module

JS.Map.Primitive.ST

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

#size Source

size :: forall r k v. STMap r k v -> ST r Int

#delete Source

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

Re-exports from JS.Map.Primitive.Internal

#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.

#thaw Source

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

Convert an immutable Map into a mutable 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.

#poke_ Source

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

#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

#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

#new Source

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

Create a new, empty mutable map

#mutate Source

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

#freeze Source

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

Convert a mutable Map into an immutable Map

#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