Control.Monad.Aff
- Package
- purescript-aff
- Repository
- slamdata/purescript-aff
#Aff Source
data Aff :: Row Effect -> Type -> Type
An Aff eff a
is an asynchronous computation with effects eff
. The
computation may either error with an exception, or produce a result of
type a
. Aff
effects are assembled from primitive Eff
effects using
makeAff
or liftEff
.
Instances
Functor (Aff eff)
Apply (Aff eff)
Applicative (Aff eff)
Bind (Aff eff)
Monad (Aff eff)
(Semigroup a) => Semigroup (Aff eff a)
(Monoid a) => Monoid (Aff eff a)
Alt (Aff eff)
Plus (Aff eff)
MonadRec (Aff eff)
MonadThrow Error (Aff eff)
MonadError Error (Aff eff)
MonadEff eff (Aff eff)
Parallel (ParAff eff) (Aff eff)
#ParAff Source
data ParAff :: Row Effect -> Type -> Type
Applicative for running parallel effects. Any Aff
can be coerced to a
ParAff
and back using the Parallel
class.
Instances
Functor (ParAff eff)
Apply (ParAff eff)
Runs effects in parallel, combining their results.
Applicative (ParAff eff)
(Semigroup a) => Semigroup (ParAff eff a)
(Monoid a) => Monoid (ParAff eff a)
Alt (ParAff eff)
Races effects in parallel. Returns the first successful result or the first error if all fail with an exception. Losing branches will be cancelled.
Plus (ParAff e)
Alternative (ParAff e)
Parallel (ParAff eff) (Aff eff)
#Canceler Source
newtype Canceler eff
A cancellation effect for actions run via makeAff
. If a Fiber
is
killed, and an async action is pending, the canceler will be called to
clean it up.
Constructors
Instances
#nonCanceler Source
nonCanceler :: forall eff. Canceler eff
A canceler which does not cancel anything.
#effCanceler Source
effCanceler :: forall eff. Eff eff Unit -> Canceler eff
A canceler from an Eff action.
#launchAff_ Source
launchAff_ :: forall a eff. Aff eff a -> Eff eff Unit
Forks an Aff
from an Eff
context, discarding the Fiber
.
#launchSuspendedAff Source
launchSuspendedAff :: forall a eff. Aff eff a -> Eff eff (Fiber eff a)
Suspends an Aff
from an Eff
context, returning the Fiber
.
#suspendAff Source
suspendAff :: forall a eff. Aff eff a -> Aff eff (Fiber eff a)
Suspends an Aff
from within a parent Aff
context, returning the Fiber
.
A suspended Aff
is not executed until a consumer observes the result
with joinFiber
.
#invincible Source
invincible :: forall a eff. Aff eff a -> Aff eff a
Runs an effect such that it cannot be killed.
#cancelWith Source
cancelWith :: forall a eff. Aff eff a -> Canceler eff -> Aff eff a
Attaches a custom Canceler
to an action. If the computation is canceled,
then the custom Canceler
will be run afterwards.
#bracket Source
bracket :: forall b a eff. Aff eff a -> (a -> Aff eff Unit) -> (a -> Aff eff b) -> Aff eff b
Guarantees resource acquisition and cleanup. The first effect may acquire some resource, while the second will dispose of it. The third effect makes use of the resource. Disposal is always run last, regardless. Neither acquisition nor disposal may be cancelled and are guaranteed to run until they complete.
#generalBracket Source
generalBracket :: forall b a eff. Aff eff a -> BracketConditions eff a b -> (a -> Aff eff b) -> Aff eff b
A general purpose bracket which lets you observe the status of the bracketed action. The bracketed action may have been killed with an exception, thrown an exception, or completed successfully.
#makeAff Source
makeAff :: forall a eff. ((Either Error a -> Eff eff Unit) -> Eff eff (Canceler eff)) -> Aff eff a
Constructs an Aff
from low-level Eff
effects using a callback. A
Canceler
effect should be returned to cancel the pending action. The
supplied callback may be invoked only once. Subsequent invocation are
ignored.
Re-exports from Control.Monad.Eff.Exception
#Error
data Error :: Type
The type of JavaScript errors
Instances
Show Error
#message
message :: Error -> String
Get the error message from a JavaScript error
#error
error :: String -> Error
Create a JavaScript error, specifying a message
Re-exports from Control.Monad.Error.Class
#catchError Source
catchError :: forall e m a. MonadError e m => m a -> (e -> m a) -> m a
#throwError Source
throwError :: forall e m a. MonadThrow e m => e -> m a
#try Source
try :: forall a m e. MonadError e m => m a -> m (Either e a)
Return Right
if the given action succeeds, Left
if it throws.
Re-exports from Control.Parallel
#parallel
parallel :: forall f m. Parallel f m => m ~> f
Re-exports from Control.Parallel.Class
#sequential
sequential :: forall f m. Parallel f m => f ~> m
Re-exports from Data.Time.Duration
#Milliseconds
newtype Milliseconds
A duration measured in milliseconds.
Constructors
Milliseconds Number
Instances
Newtype Milliseconds _
Generic Milliseconds
Eq Milliseconds
Ord Milliseconds
Semiring Milliseconds
Ring Milliseconds
Show Milliseconds
Duration Milliseconds
This instance is provided for compatibility.
Aff
is always stack-safe within a given fiber. This instance will just result in unnecessary bind overhead.