Module

Foreign.Object.ST

Package
purescript-foreign-object
Repository
purescript/purescript-foreign-object

Helper functions for working with mutable objects using the ST effect.

This module can be used when performance is important and mutation is a local effect.

#STObject Source

data STObject :: Region -> Type -> Type

A reference to a mutable object

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

The runtime representation of a value of type STObject r a is the same as that of Object a, except that mutation is allowed.

#new Source

new :: forall r a. ST r (STObject r a)

Create a new, empty mutable object

#peek Source

peek :: forall r a. String -> STObject r a -> ST r (Maybe a)

Get the value for a key in a mutable object

#poke Source

poke :: forall r a. String -> a -> STObject r a -> ST r (STObject r a)

Update the value for a key in a mutable object

#delete Source

delete :: forall r a. String -> STObject r a -> ST r (STObject r a)

Remove a key and the corresponding value from a mutable object