[Haskell] randomgen for foreign random functions

Hal Daume III hdaume at ISI.EDU
Fri Jun 25 16:38:07 EDT 2004


> What were you planning on doing with the "g" parameter?

Well, one thought would be to use some type class magicery to try to use 
this to ensure linearity, but I have no idea how to go about that.

Another thing that had crossed my mind was to use unsafeInterleaveIO to 
generate an infinite list of random #s according to the IO function and 
store these in g and then just take 1 off the head at each call...I don't 
know whether this is safe or not, though.

> AFAICT, unless you can get at c_gengam's state, you can't (safely) get
> the Haskell version out of the IO monad. OTOH, if you have a means to
> set the seed, you could combine the two into a pure function, and thus
> provide a pure (non-IO) Haskell interface. E.g. if you had:

Hrm.  Getting at its state is really a bother and, while I probably could, 
it would make me a very unhappy camper.

> [Although, in the second approach, I presume that you would need
> addtional code for multi-threaded use.]

I don't care about multi-threaded use.

 - Hal

-- 
 Hal Daume III                                   | hdaume at isi.edu
 "Arrest this man, he talks in maths."           | www.isi.edu/~hdaume



More information about the Haskell mailing list