Copyright | (c) Adam Scibior 2015-2020 |
---|---|
License | MIT |
Maintainer | leonhard.markert@tweag.io |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
SequentialT
represents a computation that can be suspended.
Synopsis
- data SequentialT m a
- suspend :: Monad m => SequentialT m ()
- finish :: Monad m => SequentialT m a -> m a
- advance :: Monad m => SequentialT m a -> SequentialT m a
- finished :: Monad m => SequentialT m a -> m Bool
- hoistFirst :: (forall x. m x -> m x) -> SequentialT m a -> SequentialT m a
- hoist :: (Monad m, Monad n) => (forall x. m x -> n x) -> SequentialT m a -> SequentialT n a
- sequentially :: Monad m => (forall x. m x -> m x) -> Int -> SequentialT m a -> m a
- sis :: Monad m => (forall x. m x -> m x) -> Int -> SequentialT m a -> m a
Documentation
data SequentialT 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 => SequentialT m () Source #
A point where the computation is paused.
finish :: Monad m => SequentialT m a -> m a Source #
Remove the remaining suspension points.
advance :: Monad m => SequentialT m a -> SequentialT m a Source #
Execute to the next suspension point. If the computation is finished, do nothing.
finish = finish . advance
finished :: Monad m => SequentialT m a -> m Bool Source #
Return True if no more suspension points remain.
hoistFirst :: (forall x. m x -> m x) -> SequentialT m a -> SequentialT 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) -> SequentialT m a -> SequentialT n a Source #
Transform the inner monad. The transformation is applied recursively through all the suspension points.
:: Monad m | |
=> (forall x. m x -> m x) | transformation |
-> Int | number of time steps |
-> SequentialT m a | |
-> m a |
Sequential importance sampling. Applies a given transformation after each time step.