# Control.Coroutine

- Package
- purescript-coroutines
- Repository
- paf31/purescript-coroutines

This module defines types and functions for working with coroutines. Coroutines are defined based on some underlying functor, which means that the same machinery can be used for coroutines which emit values, await values, fork, join, or any combination.

### #runProcess Source

`runProcess :: forall a m. MonadRec m => Process m a -> m a`

Run a `Process`

to completion.

### #Transformer Source

`type Transformer i o = Co (Transform i o)`

A type synonym for a `Co`

routine which transforms values.

### #transform Source

`transform :: forall o i m. Monad m => (i -> o) -> Transformer i o m Unit`

Transform input values.

### #CoTransform Source

`data CoTransform i o a`

A generating functor which yields a value before waiting for an input.

#### Constructors

`CoTransform o (i -> a)`

#### Instances

`Bifunctor (CoTransform i)`

`Functor (CoTransform i o)`

### #CoTransformer Source

`type CoTransformer i o = Co (CoTransform i o)`

A type synonym for a `Co`

routine which "cotransforms" values, emitting an output
before waiting for its input.

### #cotransform Source

`cotransform :: forall o i m. Monad m => o -> CoTransformer i o m i`

Cotransform input values.

### #transformCoTransformL Source

`transformCoTransformL :: forall a m f o i2 i1. MonadRec m => Parallel f m => Transformer i1 i2 m a -> CoTransformer i2 o m a -> CoTransformer i1 o m a`

Transform a `CoTransformer`

on the left.

### #transformCoTransformR Source

`transformCoTransformR :: forall a m f o2 o1 i. MonadRec m => Parallel f m => CoTransformer i o1 m a -> Transformer o1 o2 m a -> CoTransformer i o2 m a`

Transform a `CoTransformer`

on the right.

### #fuseCoTransform Source

`fuseCoTransform :: forall a m f o i. MonadRec m => Parallel f m => Transformer i o m a -> CoTransformer o i m a -> Process m a`

Fuse a transformer and a cotransformer.

### #transformProducer Source

`transformProducer :: forall a m f o i. MonadRec m => Parallel f m => Producer i m a -> Transformer i o m a -> Producer o m a`

Transform a producer.

### #($~) Source

Operator alias for Control.Coroutine.transformProducer *(right-associative / precedence 2)*

### #transformConsumer Source

`transformConsumer :: forall a m f o i. MonadRec m => Parallel f m => Transformer i o m a -> Consumer o m a -> Consumer i m a`

Transform a consumer.

### #(~$) Source

Operator alias for Control.Coroutine.transformConsumer *(right-associative / precedence 2)*

### #composeTransformers Source

`composeTransformers :: forall a m f k j i. MonadRec m => Parallel f m => Transformer i j m a -> Transformer j k m a -> Transformer i k m a`

Compose transformers

### #(~~) Source

Operator alias for Control.Coroutine.composeTransformers *(right-associative / precedence 2)*

### #composeCoTransformers Source

`composeCoTransformers :: forall a m f k j i. MonadRec m => Parallel f m => CoTransformer i j m a -> CoTransformer j k m a -> CoTransformer i k m a`

Compose cotransformers

- Modules
- Control.
Coroutine