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