Module

Control.Monad.Eff.AVar

Package
purescript-avar
Repository
slamdata/purescript-avar

#AVarEff Source

type AVarEff eff = Eff (avar :: AVAR | eff)

#AVarCallback Source

type AVarCallback eff a = Either Error a -> AVarEff eff Unit

#AVar Source

data AVar :: Type -> Type

#AVAR Source

data AVAR :: Effect

#AVarStatus Source

data AVarStatus a

Constructors

#makeEmptyVar Source

makeEmptyVar :: forall eff a. AVarEff eff (AVar a)

Creates a fresh AVar.

#makeVar Source

makeVar :: forall eff a. a -> AVarEff eff (AVar a)

Creates a fresh AVar with an initial value.

#killVar Source

killVar :: forall eff a. Error -> AVar a -> AVarEff eff Unit

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

#putVar Source

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

#tryPutVar Source

tryPutVar :: forall eff a. a -> AVar a -> AVarEff 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.

#takeVar Source

takeVar :: forall eff a. AVar a -> AVarCallback eff a -> AVarEff eff (AVarEff eff 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.

#tryTakeVar Source

tryTakeVar :: forall eff a. AVar a -> AVarEff eff (Maybe a)

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

#readVar Source

readVar :: forall eff a. AVar a -> AVarCallback eff a -> AVarEff eff (AVarEff eff Unit)

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 eff a. AVar a -> AVarEff eff (Maybe a)

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

#status Source

status :: forall eff a. AVar a -> AVarEff eff (AVarStatus a)

Synchronously checks the status of an AVar.

#isEmptyVar Source

isEmptyVar :: forall eff a. AVar a -> AVarEff eff Boolean

Synchronously checks whether an AVar currently is empty.

#isFilledVar Source

isFilledVar :: forall eff a. AVar a -> AVarEff eff Boolean

Synchronously checks whether an AVar currently has a value.

#isKilledVar Source

isKilledVar :: forall eff a. AVar a -> AVarEff eff Boolean

Synchronously checks whether an AVar has been killed.

#isEmpty Source

isEmpty :: forall a. AVarStatus a -> Boolean

#isFilled Source

isFilled :: forall a. AVarStatus a -> Boolean

#isKilled Source

isKilled :: forall a. AVarStatus a -> Boolean