
I'm very much a beginning programmer, studying Haskell. I have two questions - Firstly, I am trying to generate random numbers in Haskell, but although I have found a 'random' library on www.zvon.org, I don't really know how to include library functions, and the documentation given doesn't really tell me the effective difference between all the functions provided in the library. In another interesting development, I couldn't find any mention of this library in haskell.org's list of libraries. Secondly, but perhaps more importantly, is there a more 'beginnerish' list that I should be addressing this to? I've been following discussions on this one and they don't seem to be at quite this level. Thanks Jac

Hi!
I'm very much a beginning programmer, studying Haskell. I have two questions -
Great! Beginners are very welcome!
Firstly, I am trying to generate random numbers in Haskell, but although I have found a 'random' library on www.zvon.org, I don't really know how to include library functions, and the documentation given doesn't really tell me the effective difference between all the functions provided in the library. In another interesting development, I couldn't find any mention of this library in haskell.org's list of libraries.
You want to put 'import Random' at the top of your program. A bit of a warning, though: using random numbers isn't entirely straightforward in Haskell, due to the fact that it is a pure language (which means that you cannot have a function like 'randomInt :: () -> Int' which will return a random integer -- this is because any call to this function must always return the same result).
Secondly, but perhaps more importantly, is there a more 'beginnerish' list that I should be addressing this to? I've been following discussions on this one and they don't seem to be at quite this level.
This list is appropriate. -- Hal Daume III | hdaume@isi.edu "Arrest this man, he talks in maths." | www.isi.edu/~hdaume

On Thu, 23 Oct 2003 23:01:30 -0700 (PDT)
Hal Daume III
Hi!
I'm very much a beginning programmer, studying Haskell. I have two questions -
Great! Beginners are very welcome!
Firstly, I am trying to generate random numbers in Haskell, but although I have found a 'random' library on www.zvon.org, I don't really know how to include library functions, and the documentation given doesn't really tell me the effective difference between all the functions provided in the library. In another interesting development, I couldn't find any mention of this library in haskell.org's list of libraries.
The standard libraries are described in the Haskell Report. www.haskell.org/libraries are -other- libraries written for/using Haskell. I imagine most tutorials give at least a quick introduction to the more useful libraries. ZVON.org is meant as a reference. You can find a lists of tutorials and other learning material at www.haskell.org/learning . The Report is also fairly readable including the Random library documentation and an online version can be found at www.haskell.org/onlinereport .
You want to put 'import Random' at the top of your program. A bit of a warning, though: using random numbers isn't entirely straightforward in Haskell, due to the fact that it is a pure language (which means that you cannot have a function like 'randomInt :: () -> Int' which will return a random integer
<unhelpful poor humor: ignore this> Sherr it can return a random integer, it just has to always be the same random integer.

Jacinta wrote:
Firstly, I am trying to generate random numbers in Haskell, but although I have found a 'random' library on www.zvon.org, I don't really know how to include library functions, and the documentation given doesn't really tell me the effective difference between all the functions provided in the library. In another interesting development, I couldn't find any mention of this library in haskell.org's list of libraries.
http://www.haskell.org/onlinereport/random.html to include the library you'll need: import Random at the top of your module. Using the routines is a bit fiddly, so you might need to experiment for a while. Here's a start: dice = do { x <- getStdRandom (randomR (1::Int,6)) ; print x}
Secondly, but perhaps more importantly, is there a more 'beginnerish' list that I should be addressing this to? I've been following discussions on this one and they don't seem to be at quite this level.
I think the Haskell cafe is a fair place for such questions. I think you are from Melbourne Uni, if so we have a local newsgroup called cs.programming that you can also try. Some local Haskell people (like me) read it all the time. Cheers, Bernie.
participants (4)
-
Bernard James POPE
-
Derek Elkins
-
Hal Daume III
-
Jacinta Mary FITZGERALD