Module

Control.Monad.Aff

Package
purescript-aff
Repository
slamdata/purescript-aff

#Aff Source

data Aff :: Row Effect -> Type -> Type

An asynchronous computation with effects e. The computation either errors or produces a value of type a.

This is moral equivalent of ErrorT (ContT Unit (Eff e)) a.

Instances

#PureAff Source

type PureAff a = forall e. Aff e a

A pure asynchronous computation, having no effects other than asynchronous computation.

#Canceler Source

newtype Canceler e

A canceler is an asynchronous function that can be used to attempt the cancelation of a computation. Returns a boolean flag indicating whether or not the cancellation was successful. Many computations may be composite, in such cases the flag indicates whether any part of the computation was successfully canceled. The flag should not be used for communication.

Constructors

Instances

#cancel Source

cancel :: forall e. Canceler e -> Error -> Aff e Boolean

Unwraps the canceler function from the newtype that wraps it.

#cancelWith Source

cancelWith :: forall a e. Aff e a -> Canceler e -> Aff e a

This function allows you to attach a custom canceler to an asynchronous computation. If the computation is canceled, then the custom canceler will be run along side the computation's own canceler.

#launchAff Source

launchAff :: forall a e. Aff e a -> Eff (exception :: EXCEPTION | e) (Canceler e)

Converts the asynchronous computation into a synchronous one. All values are ignored, and if the computation produces an error, it is thrown.

Catching exceptions by using catchException with the resulting Eff computation is not recommended, as exceptions may end up being thrown asynchronously, in which case they cannot be caught.

If you do need to handle exceptions, you can use runAff instead, or you can handle the exception within the Aff computation, using catchError (or any of the other mechanisms).

#runAff Source

runAff :: forall a e. (Error -> Eff e Unit) -> (a -> Eff e Unit) -> Aff e a -> Eff e (Canceler e)

Runs the asynchronous computation. You must supply an error callback and a success callback.

Returns a canceler that can be used to attempt cancellation of the asynchronous computation.

#makeAff Source

makeAff :: forall a e. ((Error -> Eff e Unit) -> (a -> Eff e Unit) -> Eff e Unit) -> Aff e a

Creates an asynchronous effect from a function that accepts error and success callbacks. This function can be used for asynchronous computations that cannot be canceled.

#makeAff' Source

makeAff' :: forall a e. ((Error -> Eff e Unit) -> (a -> Eff e Unit) -> Eff e (Canceler e)) -> Aff e a

Creates an asynchronous effect from a function that accepts error and success callbacks, and returns a canceler for the computation. This function can be used for asynchronous computations that can be canceled.

#delay Source

delay :: forall e. Milliseconds -> Aff e Unit

Pauses execuation of the current computation for the specified number of milliseconds.

#finally Source

finally :: forall b a e. Aff e a -> Aff e b -> Aff e a

Compute aff1, followed by aff2 regardless of whether aff1 terminated successfully.

#forkAff Source

forkAff :: forall a e. Aff e a -> Aff e (Canceler e)

Forks the specified asynchronous computation so subsequent computations will not block on the result of the computation.

Returns a canceler that can be used to attempt cancellation of the forked computation.

#forkAll Source

forkAll :: forall a e f. Foldable f => f (Aff e a) -> Aff e (Canceler e)

Forks many asynchronous computation in a synchronous manner while being stack-safe up to the selected Foldable instance.

Returns a canceler that can be used to attempt cancellation of all forked computations.

#attempt Source

attempt :: forall a e. Aff e a -> Aff e (Either Error a)

Promotes any error to the value level of the asynchronous monad.

#apathize Source

apathize :: forall a e. Aff e a -> Aff e Unit

Ignores any errors.

#liftEff' Source

liftEff' :: forall a e. Eff (exception :: EXCEPTION | e) a -> Aff e (Either Error a)

Lifts a synchronous computation and makes explicit any failure from exceptions.

#nonCanceler Source

nonCanceler :: forall e. Canceler e

A constant canceller that always returns false.

#ParAff Source

newtype ParAff e a

Constructors

Instances