Module

Effect.AVar

#AVar

data AVar :: Type -> Type

#AVarCallback

#AVarStatus

data AVarStatus a

Constructors

#new

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

Creates a fresh AVar with an initial value.

#empty

empty :: forall a. Effect (AVar a)

Creates a new empty AVar.

#take

take :: forall a. AVar a -> AVarCallback a -> Effect (Effect Unit)

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. Returns an effect which will remove the callback from the pending queue.

#tryTake

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

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

#put

put :: forall a. a -> AVar a -> AVarCallback Unit -> Effect (Effect 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. Returns an effect which will remove the callback from the pending queue.

#tryPut

tryPut :: forall a. a -> AVar a -> Effect 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

read :: forall a. AVar a -> AVarCallback a -> Effect (Effect Unit)

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

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

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

#kill

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

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

#status

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

Synchronously checks the status of an AVar.

#isEmpty

isEmpty :: forall a. AVarStatus a -> Boolean

#isFilled

isFilled :: forall a. AVarStatus a -> Boolean

#isKilled

isKilled :: forall a. AVarStatus a -> Boolean

Modules