Copyright | (c) Adam Conner-Sax 2019 |
---|---|
License | BSD-3-Clause |
Maintainer | adam_conner_sax@yahoo.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Polysemy "random-fu" effect. Allows a polysemy "stack" to satisfy a MonadRandom (from "random-fu") constraint. This can be run in a few ways:
- Directly in
IO
- Using any
RandomSource
from "random-fu" - In
IO
, using a givenPureMT
source. (IO
is used to put the source in anIORef
)
Synopsis
- data RandomFu m r
- sampleRVar :: Member RandomFu effs => RVar t -> Sem effs t
- sampleDist :: (Member RandomFu effs, Distribution d t) => d t -> Sem effs t
- runRandomFuIOSimple :: forall effs a. MonadIO (Sem effs) => Sem (RandomFu ': effs) a -> Sem effs a
- runRandomFuIOPureMT :: MonadIO (Sem effs) => PureMT -> Sem (RandomFu ': effs) a -> Sem effs a
- runRandomFuFromSource :: forall s effs a. RandomSource (Sem effs) s => s -> Sem (RandomFu ': effs) a -> Sem effs a
- absorbMonadRandom :: Member RandomFu r => (forall m. MonadRandom m => m a) -> Sem r a
- type Random = RandomFu
Effect
Actions
sampleRVar :: Member RandomFu effs => RVar t -> Sem effs t Source #
Convert a random-fu RVar to the Random Effect
sampleDist :: (Member RandomFu effs, Distribution d t) => d t -> Sem effs t Source #
Convert a random-fu Distribution to the Random Effect
Interpretations
runRandomFuIOSimple :: forall effs a. MonadIO (Sem effs) => Sem (RandomFu ': effs) a -> Sem effs a Source #
Run in IO using default random-fu IO source
runRandomFuIOPureMT :: MonadIO (Sem effs) => PureMT -> Sem (RandomFu ': effs) a -> Sem effs a Source #
Run in IO
, using the given PureMT
source stored in an IORef
runRandomFuFromSource :: forall s effs a. RandomSource (Sem effs) s => s -> Sem (RandomFu ': effs) a -> Sem effs a Source #
Run using the given source
Interop
absorbMonadRandom :: Member RandomFu r => (forall m. MonadRandom m => m a) -> Sem r a Source #
Given a function that uses the random-fu package and produces a result thusly
constrained by MonadRandom
, absorb it into a Polysemy monad whose
effect list contains the RandomFu effect.