packages feed

comonad-random 0.1.0 → 0.1.1

raw patch · 2 files changed

+9/−18 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Control/Comonad/Random.hs view
@@ -104,24 +104,15 @@  {- $Example -   This example is based on the example given in the MonadRandom-   package.--   @rolls@ is a supply of random dice rolls, picking a number between-   1 and 6, inclusive.--> rolls :: RandomGen g => g -> Rand Int-> rolls = mkRandR (1, 6)--   @extractN@ may be used to supply @n@ values from a @Rand@.--> extractN :: Int -> Rand a -> [a]-> extractN n = take n . extracts next--   We can bootstrap the whole thing with a generator, giving us a pure-   interface to the random values.+   The following function generates an infinite list of dice throw+   sums with @n@ dice. -> main = print . extractN 2 . rolls =<< getStdGen+> rolls :: RandomGen g => Int -> g -> [Int]+> rolls n =+>     extracts left          .  -- Extract an infinite list of the sums.+>     fmap (sum . take n)    .  -- Sum the first n values of each list.+>     extend (extracts next) .  -- Group them into lists of die values.+>     mkRandR (1,6)             -- Generate random die values.     One potential gotcha with this library is that a top-level @Rand@    that is extracted deeply could result in a space leak due to the
comonad-random.cabal view
@@ -1,5 +1,5 @@ name:                comonad-random-version:             0.1.0+version:             0.1.1 synopsis:            Comonadic interface for random values description:         Comonadic interface for random values category:            Control