Copyright | (c) Adam Scibior 2015-2020 |
---|---|
License | MIT |
Maintainer | leonhard.markert@tweag.io |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Sequential
represents a computation that can be suspended.
Synopsis
- data Sequential m a
- suspend :: Monad m => Sequential m ()
- finish :: Monad m => Sequential m a -> m a
- advance :: Monad m => Sequential m a -> Sequential m a
- finished :: Monad m => Sequential m a -> m Bool
- hoistFirst :: (forall x. m x -> m x) -> Sequential m a -> Sequential m a
- hoist :: (Monad m, Monad n) => (forall x. m x -> n x) -> Sequential m a -> Sequential n a
- sis :: Monad m => (forall x. m x -> m x) -> Int -> Sequential m a -> m a
Documentation
data Sequential m a Source #
Represents a computation that can be suspended at certain points.
The intermediate monadic effects can be extracted, which is particularly
useful for implementation of Sequential Monte Carlo related methods.
All the probabilistic effects are lifted from the transformed monad, but
also suspend
is inserted after each factor
.
Instances
suspend :: Monad m => Sequential m () Source #
A point where the computation is paused.
finish :: Monad m => Sequential m a -> m a Source #
Remove the remaining suspension points.
advance :: Monad m => Sequential m a -> Sequential m a Source #
Execute to the next suspension point. If the computation is finished, do nothing.
finish = finish . advance
finished :: Monad m => Sequential m a -> m Bool Source #
Return True if no more suspension points remain.
hoistFirst :: (forall x. m x -> m x) -> Sequential m a -> Sequential m a Source #
Transform the inner monad. This operation only applies to computation up to the first suspension.
hoist :: (Monad m, Monad n) => (forall x. m x -> n x) -> Sequential m a -> Sequential n a Source #
Transform the inner monad. The transformation is applied recursively through all the suspension points.