Copyright | (c) Adam Scibior 2015-2020 |
---|---|
License | MIT |
Maintainer | leonhard.markert@tweag.io |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
FreeSampler
is a free monad transformer over random sampling.
Synopsis
- data FreeSampler m a
- hoist :: (Monad m, Monad n) => (forall x. m x -> n x) -> FreeSampler m a -> FreeSampler n a
- interpret :: MonadSample m => FreeSampler m a -> m a
- withRandomness :: Monad m => [Double] -> FreeSampler m a -> m a
- withPartialRandomness :: MonadSample m => [Double] -> FreeSampler m a -> m (a, [Double])
- runWith :: MonadSample m => [Double] -> FreeSampler Identity a -> m (a, [Double])
Documentation
data FreeSampler m a Source #
Free monad transformer over random sampling.
Uses the Church-encoded version of the free monad for efficiency.
Instances
hoist :: (Monad m, Monad n) => (forall x. m x -> n x) -> FreeSampler m a -> FreeSampler n a Source #
Hoist FreeSampler
through a monad transform.
interpret :: MonadSample m => FreeSampler m a -> m a Source #
Execute random sampling in the transformed monad.
withRandomness :: Monad m => [Double] -> FreeSampler m a -> m a Source #
Execute computation with supplied values for random choices.
withPartialRandomness :: MonadSample m => [Double] -> FreeSampler m a -> m (a, [Double]) Source #
Execute computation with supplied values for a subset of random choices. Return the output value and a record of all random choices used, whether taken as input or drawn using the transformed monad.
runWith :: MonadSample m => [Double] -> FreeSampler Identity a -> m (a, [Double]) Source #
Like withPartialRandomness
, but use an arbitrary sampling monad.