[Haskell] help -- need a random number

2007-04-26 Thread robert bauer
Hi, I need some random numbers. The documentation identifies StdGen, but I can't figure out how to invoke it. The documentation is great in every way, except an actual example that I can essentially cut and paste. Thanks ___ Haskell mailing list

Re: [Haskell] help -- need a random number

2007-04-26 Thread Johannes Waldmann
I need some random numbers. in the IO Monad, hiding the use of a generator do x - randomRIO (0, 1 :: Double) ; print x you can also make the state explicit: do g0 - getStdGen ; let { ( x, g1 ) = randomR ( 0, 1::Double) g0 } ; print x a RandomGen is actually the state object for the

Re: [Haskell] help -- need a random number

2007-04-26 Thread Marc A. Ziegert
module Dice where import System.Random import System.IO.Unsafe (unsafePerformIO,unsafeInterleaveIO) import Data.List (unfoldr) dice4,dice6,dice8,dice10,dice12,dice20,dice666 :: [Int] dice4 = randomRs (1,4) (read foo::StdGen) dice6 = randomRs (1,6) (mkStdGen 5) dice8 = randomRs (1,8)

Re: [Haskell] help -- need a random number

2007-04-26 Thread Johannes Waldmann
import System.IO.Unsafe (unsafePerformIO,unsafeInterleaveIO) Whoa! I'd be very cautious recommending these for newbies ... ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell

Re: [Haskell] help -- need a random number

2007-04-26 Thread Marc A. Ziegert
that is exact the way, how i had learned about the state monads like IO and Maybe. that was even before i understood the [] monad, folding and using Random; i don't remember when that was... ghc-5.xx age. in my opinion, unsafePerformIO is a good learning tool, as soon as you use it tricky to

Re: help need

2002-04-15 Thread Arjan van IJzendoorn
Hi Benny, instance (Float a) = Num (Poly a) where x + y = addPoly x y I got the Cannot use type synonym in instance head error message when I was trying to compile the above code. Can you tell me why and how to solve it? Unfortunately, you can not instantiate a class

Re: Help need Cannot use type synonym in instance head

2002-04-14 Thread Jon Cast
Please keep this on the list, so everyone can benefit. Benny [EMAIL PROTECTED] wrote: Hello Jon Thanks for the help. But it still didn't work after I changed the codes from: type Poly = [Float] addPoly::Poly-Poly-Poly addPoly x y = zipWith (+) x y instance (Float a) = Num (Poly a)

help need

2002-04-13 Thread Benny
type Poly = [Float] addPoly::Poly-Poly-PolyaddPoly x y = zipWith (+) x y instance (Float a) = Num (Poly a) where x + y= addPoly x y I got the "Cannot use type synonym in instance head" error message when I was trying to compile the above code. Can you tell me why and how to solve it?

Help need Cannot use type synonym in instance head

2002-04-13 Thread Benny
type Poly = [Float] addPoly::Poly-Poly-PolyaddPoly x y = zipWith (+) x y instance (Float a) = Num (Poly a) where (+) = addPoly I got the error message "Cannot use type synonym in instance head" when I was trying to compile the codes above. Can anyone tell me why and how to solve it?

Re: Help need Cannot use type synonym in instance head

2002-04-13 Thread Ashley Yakeley
At 2002-04-13 21:22, Benny wrote: type Poly = [Float] addPoly::Poly-Poly-Poly addPoly x y = zipWith (+) x y instance (Float a) = Num (Poly a) where (+) = addPoly I got the error message Cannot use type synonym in instance head when I was trying to compile the codes above. Can