[Haskell-beginners] To use random number monad inside function

Krzysztof Skrzętnicki gtener at gmail.com
Tue Jan 27 22:57:41 EST 2009

You need to store random generator seed somewhere and keep track of updated
value after calling randomness-related functions.You can try doing it
manually, but what really fits here is monad that keeps track of that seed
value. Good news is: there is already package with such monad on Hackage. In
particular, try package MonadRandom (
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MonadRandom-0.1.3 ).
If you have cabal-install, you can simply get it with "cabal install
monadrandom" (and if you don't have cabal-install, you should get this
wonderful tool right now!).

There are some examples within the documentation here:

All best

Christopher Skrzętnicki

On Wed, Jan 28, 2009 at 04:33, Erick González <erickgc at instec.cu> wrote:

>  Hi:
> Haskell' s way of random number generation is strange to me, but I know how
> to do that. I' d like to know how can I call random numbers generated on the
> screen inside a classic function. I mean, I need to know the way of calling
> random numbers (one different every time that I run) inside a function.
> Please, Could anybody help me?
> Thanks
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090128/96e85197/attachment-0001.htm

More information about the Beginners mailing list