Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

## Synopsis

- data Wait diff a = Wait diff a
- type ScheduleT diff = FreeT (Wait diff)
- wait :: Monad m => diff -> ScheduleT diff m ()
- runScheduleT :: Monad m => (diff -> m ()) -> ScheduleT diff m a -> m a
- runScheduleIO :: (MonadIO m, Integral n) => ScheduleT n m a -> m a
- race :: (Ord diff, Num diff, Monad m) => ScheduleT diff m a -> ScheduleT diff m b -> ScheduleT diff m (Either (a, ScheduleT diff m b) (ScheduleT diff m a, b))
- async :: (Ord diff, Num diff, Monad m) => ScheduleT diff m a -> ScheduleT diff m b -> ScheduleT diff m (a, b)

# Documentation

A functor implementing a syntactical "waiting" action.

`diff`

represents the duration to wait.`a`

is the encapsulated value.

Wait diff a |

type ScheduleT diff = FreeT (Wait diff) Source #

Values in `ScheduleT diff m`

are delayed computations with side effects in `m`

.
Delays can occur between any two side effects, with lengths specified by a `diff`

value.
These delays don't have any semantics, it can be given to them with `runScheduleT`

.

wait :: Monad m => diff -> ScheduleT diff m () Source #

The side effect that waits for a specified amount.

runScheduleT :: Monad m => (diff -> m ()) -> ScheduleT diff m a -> m a Source #

Supply a semantic meaning to `Wait`

.
For every occurrence of `Wait diff`

in the `ScheduleT diff m a`

value,
a waiting action is executed, depending on `diff`

.

race :: (Ord diff, Num diff, Monad m) => ScheduleT diff m a -> ScheduleT diff m b -> ScheduleT diff m (Either (a, ScheduleT diff m b) (ScheduleT diff m a, b)) Source #

Runs two values in `ScheduleT`

concurrently
and returns the first one that yields a value
(defaulting to the first argument),
and a continuation for the other value.