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 Random m r
- sampleRVar :: Member Random effs => RVar t -> Sem effs t
- sampleDist :: (Member Random effs, Distribution d t) => d t -> Sem effs t
- runRandomIOSimple :: forall effs a. MonadIO (Sem effs) => Sem (Random ': effs) a -> Sem effs a
- runRandomIOPureMT :: MonadIO (Sem effs) => PureMT -> Sem (Random ': effs) a -> Sem effs a
- runRandomFromSource :: forall s effs a. RandomSource (Sem effs) s => s -> Sem (Random ': effs) a -> Sem effs a
Effect
Actions
sampleRVar :: Member Random effs => RVar t -> Sem effs t Source #
Convert a random-fu RVar to the Random Effect
sampleDist :: (Member Random effs, Distribution d t) => d t -> Sem effs t Source #
Convert a random-fu Distribution to the Random Effect
Interpretations
runRandomIOSimple :: forall effs a. MonadIO (Sem effs) => Sem (Random ': effs) a -> Sem effs a Source #
Run in IO using default random-fu IO source
runRandomIOPureMT :: MonadIO (Sem effs) => PureMT -> Sem (Random ': effs) a -> Sem effs a Source #
Run in IO
, using the given PureMT
source stored in an IORef
runRandomFromSource :: forall s effs a. RandomSource (Sem effs) s => s -> Sem (Random ': effs) a -> Sem effs a Source #
Run using the given source
Orphan instances
Member (Random :: (Type -> Type) -> Type -> Type) effs => MonadRandom (Sem effs) Source # | supply instance of MonadRandom for functions which require it |
getRandomPrim :: Prim t -> Sem effs t # getRandomWord8 :: Sem effs Word8 # getRandomWord16 :: Sem effs Word16 # getRandomWord32 :: Sem effs Word32 # getRandomWord64 :: Sem effs Word64 # getRandomDouble :: Sem effs Double # getRandomNByteInteger :: Int -> Sem effs Integer # |