[Haskell-cafe] Just how unsafe is unsafe

Yitzchak Gale gale at sefer.org
Sun Feb 8 09:32:33 EST 2009

Peter Verswyvelen wrote:
>>> I do have asked myself the question whether
>>> a "really random generating"
>>> function could be regarded as "pure" somehow

I wrote:
>> Not really...

Alberto G. Corona wrote:
> What is pure randomness? .When  the algorithmic complexity of the list of
> random number is equal to the lenght of the list, that is, is incompressible
> by any means. But this can not be probed. the distribution of values gives a
> hint of whether if the list obey any algorithm, but even so, many
> compressible series have a random distribution. in practical terms, it is
> random has a random distribution,  the receiver does not know the algorithm
> AND the initial value.  In this case it can be pure.

Perhaps philosophically you can consider it pure,
but it is unsafe to treat it as pure in your program.
If you write

x = genRandomR (1, 100)

then the compiler may or may not replace the variable
x by the function application genRandomR (1, 100)
anywhere in your program. That is probably not what you


More information about the Haskell-Cafe mailing list