Module

Control.Monad.Aff.AVar

Package
purescript-aff
Repository
slamdata/purescript-aff

#makeVar Source

makeVar :: forall a eff. a -> Aff (avar :: AVAR | eff) (AVar a)

Creates a fresh AVar with an initial value.

#makeEmptyVar Source

makeEmptyVar :: forall a eff. Aff (avar :: AVAR | eff) (AVar a)

Creates a fresh AVar.

#status Source

status :: forall a eff. AVar a -> Aff (avar :: AVAR | eff) (AVarStatus a)

Synchronously checks the status of an AVar.

#isEmptyVar Source

isEmptyVar :: forall a eff. AVar a -> Aff (avar :: AVAR | eff) Boolean

Synchronously checks whether an AVar currently is empty.

#isFilledVar Source

isFilledVar :: forall a eff. AVar a -> Aff (avar :: AVAR | eff) Boolean

Synchronously checks whether an AVar currently has a value.

#isKilledVar Source

isKilledVar :: forall a eff. AVar a -> Aff (avar :: AVAR | eff) Boolean

Synchronously checks whether an AVar has been killed.

#takeVar Source

takeVar :: forall a eff. AVar a -> Aff (avar :: AVAR | eff) 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.

#tryTakeVar Source

tryTakeVar :: forall a eff. AVar a -> Aff (avar :: AVAR | eff) (Maybe a)

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

#putVar Source

putVar :: forall a eff. a -> AVar a -> Aff (avar :: AVAR | eff) 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.

#tryPutVar Source

tryPutVar :: forall a eff. a -> AVar a -> Aff (avar :: AVAR | eff) 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.

#readVar Source

readVar :: forall a eff. AVar a -> Aff (avar :: AVAR | eff) a

Reads the AVar value. Unlike takeVar, 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.

#tryReadVar Source

tryReadVar :: forall a eff. AVar a -> Aff (avar :: AVAR | eff) (Maybe a)

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

#killVar Source

killVar :: forall a eff. Error -> AVar a -> Aff (avar :: AVAR | eff) Unit

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

Re-exports from Control.Monad.Eff.AVar

#AVarStatus Source

data AVarStatus a

Constructors

#AVar Source

data AVar :: Type -> Type

#AVAR Source

data AVAR :: Effect

#isKilled Source

isKilled :: forall a. AVarStatus a -> Boolean

#isFilled Source

isFilled :: forall a. AVarStatus a -> Boolean

#isEmpty Source

isEmpty :: forall a. AVarStatus a -> Boolean