monad-bayes-1.1.0: A library for probabilistic programming.
Copyright(c) Adam Scibior 2015-2020
LicenseMIT
Maintainerleonhard.markert@tweag.io
Stabilityexperimental
PortabilityGHC
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Bayes.Sequential.Coroutine

Description

Sequential represents a computation that can be suspended.

Synopsis

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

Instances details
MonadTrans Sequential Source # 
Instance details

Defined in Control.Monad.Bayes.Sequential.Coroutine

Methods

lift :: Monad m => m a -> Sequential m a #

MonadIO m => MonadIO (Sequential m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sequential.Coroutine

Methods

liftIO :: IO a -> Sequential m a #

Monad m => Applicative (Sequential m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sequential.Coroutine

Methods

pure :: a -> Sequential m a #

(<*>) :: Sequential m (a -> b) -> Sequential m a -> Sequential m b #

liftA2 :: (a -> b -> c) -> Sequential m a -> Sequential m b -> Sequential m c #

(*>) :: Sequential m a -> Sequential m b -> Sequential m b #

(<*) :: Sequential m a -> Sequential m b -> Sequential m a #

Functor m => Functor (Sequential m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sequential.Coroutine

Methods

fmap :: (a -> b) -> Sequential m a -> Sequential m b #

(<$) :: a -> Sequential m b -> Sequential m a #

Monad m => Monad (Sequential m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sequential.Coroutine

Methods

(>>=) :: Sequential m a -> (a -> Sequential m b) -> Sequential m b #

(>>) :: Sequential m a -> Sequential m b -> Sequential m b #

return :: a -> Sequential m a #

MonadDistribution m => MonadDistribution (Sequential m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sequential.Coroutine

MonadFactor m => MonadFactor (Sequential m) Source #

Execution is suspended after each score.

Instance details

Defined in Control.Monad.Bayes.Sequential.Coroutine

Methods

score :: Log Double -> Sequential m () Source #

MonadMeasure m => MonadMeasure (Sequential m) Source # 
Instance details

Defined in Control.Monad.Bayes.Sequential.Coroutine

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.

sequentially Source #

Arguments

:: Monad m 
=> (forall x. m x -> m x)

transformation

-> Int

number of time steps

-> Sequential m a 
-> m a 

Sequential importance sampling. Applies a given transformation after each time step.

sis Source #

Arguments

:: Monad m 
=> (forall x. m x -> m x)

transformation

-> Int

number of time steps

-> Sequential m a 
-> m a 

synonym

Sequential importance sampling. Applies a given transformation after each time step.