# Effect.Aff.Unlift

- Package
- purescript-unlift
- Repository
- tweag/purescript-unlift

### #MonadUnliftAff Source

`class MonadUnliftAff :: (Type -> Type) -> Constraint`

`class (MonadAff m) <= MonadUnliftAff m where`

Monads which allow their actions to be run in `Aff`

.

`MonadUnliftAff`

captures the opposite notion of `MonadAff`

- while
`MonadAff`

allows an `Aff`

to be lifted into another monad,
`MonadUnliftAff`

allows a monad other than `Aff`

to be run in an
`Aff`

context.

Note that the laws given below require that a monad have no "monadic
state", which essentially limits instances to `ReaderT`

stacks with a
base of `Aff`

.

Instances should satisfy the following laws, which state that
`unliftAff`

is a transformer of monads for any given `u`

returned by
`askUnliftAff`

:.

```
unliftAff u <<< pure = pure
unliftAff u (f =<< m) = unliftAff u <<< f =<< unliftAff u m
```

#### Members

`withRunInAff :: forall b. ((m ~> Aff) -> Aff b) -> m b`

#### Instances

`MonadUnliftAff Aff`

`(MonadUnliftAff m) => MonadUnliftAff (ReaderT r m)`

### #askUnliftAff Source

`askUnliftAff :: forall m. MonadUnliftAff m => m (UnliftAff m)`

Returns a natural transformation from `m`

to `Aff`

within an `m`

context.
This can subsequently be used to run `m`

actions directly in `Aff`

.

### #askRunInAff Source

`askRunInAff :: forall m a. MonadUnliftAff m => m (m a -> Aff a)`

A monomorphic version of askUnliftAff which can be more convenient when you only want to use the resulting runner function once with a concrete type.

If you run into type issues using this, try using `askUnlitAff`

instead.

### #withUnliftAff Source

`withUnliftAff :: forall m a. MonadUnliftAff m => (UnliftAff m -> Aff a) -> m a`

A version of `withRunInAff`

that provides an `UnliftAff`

wrapper
instead of a rank-2 polymorphic function.

### #toAff Source

`toAff :: forall m a. MonadUnliftAff m => m a -> m (Aff a)`

Run the given action inside the `Aff`

monad.

Run an

`Aff`

with access to a runner function that is capable of running a monadic action`m`

in`Aff`

.