[Haskell] Re: About Random Integer without IO

Clive Brettingham-Moore haskell at brettingham-moore.net
Thu Nov 11 21:06:47 EST 2004

This really really should have moved to haskell-cafe as previously
suggested (sending to both with this in mind); apologies for being a
little confising to haskell-cafe

This isn't a language design issue, it is a FAQ, or at best a nebulous
conceptual debate (speaking of which, has anyone got something more
specific than http://www.haskell.org/hawiki/ThatAnnoyingIoType). This
question comes up again and again with Haskell newbies - the answer is of
course you can't - not  maybe, not sometimes, not sort of, but no.

What you can do is confine the IO-ness at the outermost layer of the
program - by seeding a psudo-random list at program initialization, as
both solutions suggested - giving the original question the benefit of the
doubt, we'll assume this was what the questioner wanted.

Suggesting parameters is not an escape - it is exactly the same as using 
/dev/random in that they are also IO, weaker IO but still IO (getArgs:: IO
[String], though there are counter arguments); besides, reproducability
was not a requirement mentioned or implied by the original question
(though relevent, not actually haskell specific.. haskell-cafe, again).

Chaotic is not the same as Random (Jerzy you obviously know this, but
please be clear about it, don't add to the confusion). Chaotic algoritms
are used as a 'random-extender'. Random only happens when you seed you
algorithm with a non-deterministic value (ie random).

karczma wrote:
> noise). I generated random fractals, etc. It didn't cost me anything to
> put different initializations by hand on every run when I wanted to have
> different behaviour. But it was MUCH more important to repeat the same
> sequence, e.g., after making fast some nice fractal sketch, I relaunched
> the program with bigger size/precision, but exploiting the same random
> sequence. I repeat, such is my philosophy. Yours is easier, since you are
> just discussing, most probably you never used RN for a serious work. If
> I am wrong, I apologize.
> Jerzy K.

I have to say this.. SERIOUS WORK?!
I don't know what Thomas does, but I'm working with security at the
moment, and a "serious" random program with default constant seeding
strikes me as serious and not in a good way. Overridable seeding sure, if
the application demands it, but not broken by default. It's not random; it
may be alright for screensavers, but it's not a good coding habit.

(Sorry, pet peeve)

More information about the Haskell mailing list