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

Creates a fresh AVar.

#makeVar Source

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

Creates a fresh AVar with an initial value.

#killVar Source

killVar :: forall a eff. 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 a eff. 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 a eff. 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 a eff. 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 a eff. 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 a eff. 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 a eff. 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 a eff. AVar a -> AVarEff eff (AVarStatus a)

Synchronously checks the status of an AVar.

#isEmptyVar Source

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

Synchronously checks whether an AVar currently is empty.

#isFilledVar Source

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

Synchronously checks whether an AVar currently has a value.

#isKilledVar Source

isKilledVar :: forall a eff. 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