[Haskell-beginners] MonadRandom or Control.Monad.Random

Michael P Mossey mpm at alumni.caltech.edu
Fri Jul 31 20:55:43 EDT 2009


Brent Yorgey wrote:
> On Thu, Jul 30, 2009 at 05:04:54PM -0700, Michael P Mossey wrote:
>> Where can I find MonadRandom or Control.Monad.Random to install? It doesn't 
>> seem to be a system library, I can't find it with cabal or Hoogle.
> 
> 'cabal install MonadRandom' ought to work.  Note that you may have to
> 'cabal update' first to make sure cabal has the most up-to-date
> package list.  You can also always look at the complete list of
> packages on Hackage by going to hackage.haskell.org.
> 
> -Brent
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners

That worked.

I'm looking at this example from the docs. I understand most of this but I can't 
find a definition of getRandomR. See die has type (Rand g Int) I'm assuming 
getRandomR is a function that has that type, but I can't find its definition.


import Control.Monad.Random

die :: (RandomGen g) => Rand g Int
die = getRandomR (1,6)

dice :: (RandomGen g) => Int -> Rand g [Int]
dice n = sequence (replicate n die)

main = do
   values <- evalRandIO (dice 2)
   putStrLn (show values)





More information about the Beginners mailing list