Module

Effect.Aff.AVar

Package
purescript-avar
Repository
purescript-contrib/purescript-avar

#new Source

new :: forall a. a -> Aff (AVar a)

Creates a fresh AVar with an initial value.

#empty Source

empty :: forall a. Aff (AVar a)

Creates a fresh AVar.

#status Source

status :: forall a. AVar a -> Aff (AVarStatus a)

Synchronously checks the status of an AVar.

#take Source

take :: forall a. AVar a -> Aff a

Takes the AVar value, leaving it empty. If the AVar is already empty, the callback will be queued until the AVar is filled. Multiple takes will resolve in order as the AVar fills.

#tryTake Source

tryTake :: forall a. AVar a -> Aff (Maybe a)

Attempts to synchronously take an AVar value, leaving it empty. If the AVar is empty, this will return Nothing.

#put Source

put :: forall a. a -> AVar a -> Aff Unit

Sets the value of the AVar. If the AVar is already filled, it will be queued until the value is emptied. Multiple puts will resolve in order as the AVar becomes available.

#tryPut Source

tryPut :: forall a. a -> AVar a -> Aff Boolean

Attempts to synchronously fill an AVar. If the AVar is already filled, this will do nothing. Returns true or false depending on if it succeeded.

#read Source

read :: forall a. AVar a -> Aff a

Reads the AVar value. Unlike take, this will not leave the AVar empty. If the AVar is empty, this will queue until it is filled. Multiple reads will resolve at the same time, as soon as possible.

#tryRead Source

tryRead :: forall a. AVar a -> Aff (Maybe a)

Attempts to synchronously read an AVar. If the AVar is empty, this will return Nothing.

#kill Source

kill :: forall a. Error -> AVar a -> Aff Unit

Kills the AVar with an exception. All pending and future actions will resolve immediately with the provided exception.

Re-exports from Effect.AVar

#AVarStatus Source

data AVarStatus a

Constructors

#AVar Source

data AVar t0

#isKilled Source

isKilled :: forall a. AVarStatus a -> Boolean

#isFilled Source

isFilled :: forall a. AVarStatus a -> Boolean

#isEmpty Source

isEmpty :: forall a. AVarStatus a -> Boolean