polysemy-RandomFu: Experimental, RandomFu effect and interpreters for polysemy

[ bsd3, library, polysemy ] [ Propose Tags ]

Please see the README on GitHub at https://github.com/adamConnerSax/polysemy-Extra/tree/master/polysemy-RandomFu#polysemy-randomfu

[Skip to Readme]
Versions [faq],,,,
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), polysemy (>=1.3.0 && <1.4), polysemy-plugin (>0.2.0 && <0.4), polysemy-zoo (>=0.6.0 && <0.8), random-fu (>= && <, random-source (>=0.3 && < [details]
License BSD-3-Clause
Copyright 2019 Adam Conner-Sax
Author Adam Conner-Sax
Maintainer adam_conner_sax@yahoo.com
Category Polysemy
Home page https://github.com/adamConnerSax/polysemy-Extra#readme
Bug tracker https://github.com/adamConnerSax/polysemy-Extra/issues
Source repo head: git clone https://github.com/adamConnerSax/polysemy-Extra(polysemy-RandomFu)
Uploaded by adamCS at 2020-02-20T16:58:33Z
Distributions NixOS:
Downloads 1389 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs not available [build log]
Last success reported on 2020-02-20 [all 2 reports]


  • Polysemy
    • ConstraintAbsorber
      • Polysemy.ConstraintAbsorber.MonadRandom
    • Polysemy.RandomFu


Maintainer's Corner

For package maintainers and hackage trustees

Readme for polysemy-RandomFu-

[back to package description]

polysemy-RandomFu v0.4.0.0

Build Status Hackage Hackage Dependencies


Example (from the tests)

import           Polysemy
import           Polysemy.RandomFu

import qualified Data.Random                   as R
import qualified Data.Random.Source.PureMT     as R

getRandomInts :: Member RandomFu r => Int -> Sem r [Int]
getRandomInts nDraws =
  sampleRVar $ M.replicateM nDraws (R.uniform 0 (100 :: Int))
main :: IO ()
main = do
  seed <- R.newPureMT
  putStrLn . show $ runM . runRandomIOPureMT (R.pureMT seed) $ getRandomInts 5

should print a list of 5 pseudo-random integers. They will be different each time you run because the newPureMT function returns a different seed each time it's called. If you replace that seed in the R.pureMT argument to runRandomIOPureMT with a fixed number then you will get the same pseudo-random sequences each time. This can be useful for testing.