# Search results

### M Effect

This module provides the `Effect`

type, which is used to represent
*native* effects. The `Effect`

type provides a typed API for effectful
computations, while at the same time generating efficient JavaScript.

A native effect. The type parameter denotes the return type of running the
effect, that is, an `Effect Int`

is a possibly-effectful computation which
eventually produces a value of the type `Int`

when it finishes.

Type synonym for using `Effect`

as an effect.

`effect :: forall a n. Named n { cause :: a, effect :: a } -> Named (Effect n) a`

`effect :: forall props a. String -> Effect (a -> a) -> FormBuilder props a a`

A dummy form that, whenever the specified key changes, performs an effect. It sets the form data to the result of the effect and returns it.

An `Effect`

with base type `st`

.

`effect0 :: forall b a. String -> a -> b`

The base functor of the `Effect`

free monad.

`effectful :: forall f output. Effectful f output => f -> output`

This module defines the `Ref`

type for mutable value references, as well
as actions for working with them.

You'll notice that all of the functions that operate on a `Ref`

(e.g.
`new`

, `read`

, `write`

) return their result wrapped in an `Effect`

.
Working with mutable references is considered effectful in PureScript
because of the principle of purity: functions should not have side
effects, and should return the same result when called with the same
arguments. If a `Ref`

could be written to without using `Effect`

, that
would cause a side effect (the effect of changing the result of subsequent
reads for that `Ref`

). If there were a function for reading the current
value of a `Ref`

without the result being wrapped in `Effect`

, the result
of calling that function would change each time a new value was written to
the `Ref`

. Even creating a new `Ref`

is effectful: if there were a
function for creating a new `Ref`

with the type `forall s. s -> Ref s`

,
then calling that function twice with the same argument would not give the
same result in each case, since you'd end up with two distinct references
which could be updated independently of each other.

*Note*: `Control.Monad.ST`

provides a pure alternative to `Ref`

when
mutation is restricted to a local scope.

`EffectFnAff :: forall a. (EffectFn2 (EffectFnCb Error) (EffectFnCb a) EffectFnCanceler) -> EffectFnAff a`

`effectCrash :: forall a. String -> Effect a`

`effectfully :: forall st eff a. (st -> Aff eff a) -> Effect eff st a`

Perform a `Control.Monad.Aff`

action and return a result.

`effectsOver :: forall @f @a. Functor f => FreeS f a -> Array (f Unit)`

Collect every possible effect into an `Array`

.

`effectToPoll :: Effect ~> Poll`

Turn an Effect into a poll

`effectsUnder :: forall @f @a. Functor f => FreeS f a -> Array (f Unit)`

Collect every required effect into an `Array`

.

`effectScatter :: forall m i. Monad m => (CommandsT EffectScatterI m) ~> (CommandsT (effectScatter :: I | i) m)`