Module

Neon.Effect

Package
purescript-neon
Repository
tfausak/purescript-neon

Types and functions for dealing with effects. Includes synchronous effects (Eff) as well as effectful types (like CONSOLE).

#catch Source

catch :: forall b a. (Error -> Eff b a) -> Eff (exception :: EXCEPTION | b) a -> Eff b a

Catches an exception by providing and exception handler. The handler removes the EXCEPTION effect.

catch (\ x -> error x) (throw (exception "example")))

#throw Source

throw :: forall b a. Error -> Eff (exception :: EXCEPTION | b) a

Throws an exception.

throw (exception "example"))

Re-exports from Control.Monad.Eff

#Eff Source

data Eff :: Row Effect -> Type -> Type

The Eff type constructor is used to represent native effects.

See Handling Native Effects with the Eff Monad for more details.

The first type parameter is a row of effects which represents the contexts in which a computation can be run, and the second type parameter is the return type.

Instances

#runPure Source

runPure :: forall a. Pure a -> a

Run a pure computation and return its result.

Re-exports from Control.Monad.Eff.Console

#CONSOLE Source

data CONSOLE :: Effect

The CONSOLE effect represents those computations which write to the console.

#log Source

log :: forall eff. String -> Eff (console :: CONSOLE | eff) Unit

Write a message to the console.

#error Source

error :: forall eff. String -> Eff (console :: CONSOLE | eff) Unit

Write an error to the console.

Re-exports from Control.Monad.Eff.Exception

#EXCEPTION

data EXCEPTION :: Effect

This effect is used to annotate code which possibly throws exceptions

Re-exports from Control.Monad.Eff.Random

#RANDOM Source

data RANDOM :: Effect

The RANDOM effect indicates that an Eff action may access or modify the JavaScript global random number generator, i.e. Math.random().

Re-exports from Control.Monad.Eff.Unsafe

#unsafePerformEff Source

unsafePerformEff :: forall a eff. Eff eff a -> a

Run an effectful computation.

Note: use of this function can result in arbitrary side-effects.