Re: [Haskell] randomgen for foreign random functions

2004-06-28 Thread Jan-Willem Maessen - Sun Labs East
Simon Peyton-Jones wrote (in response to Hal Daume): | basically, i want to wrap this up as something like: | | gengam :: RandomGen g => g -> Double -> Double -> (g, Double) | | analogously to the normal random # generation stuff. There's a standard approach, originally due to Lennart Augustsson

RE: [Haskell] randomgen for foreign random functions

2004-06-28 Thread Simon Peyton-Jones
| Say I have a foreign function: | | foreign import ccall "statistical_c.h gengam" c_gengam :: CDouble -> CDouble -> IO CDouble | | that returns a random value parameterized by the two CDoubles. clearly | this must happen in IO since the return value will be different each time, | and some gl

Re: [Haskell] randomgen for foreign random functions

2004-06-25 Thread Hal Daume III
> 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

Re: [Haskell] randomgen for foreign random functions

2004-06-25 Thread Jan-Willem Maessen
On Fri, 2004-06-25 at 12:42, Hal Daume III wrote: > Hi All -- > > Say I have a foreign function: > > foreign import ccall "statistical_c.h gengam" c_gengam :: CDouble -> CDouble -> > IO CDouble > > that returns a random value parameterized by the two CDoubles. clearly > this must happen i

Re: [Haskell] randomgen for foreign random functions

2004-06-25 Thread Glynn Clements
Hal Daume III wrote: > Say I have a foreign function: > > foreign import ccall "statistical_c.h gengam" c_gengam :: CDouble -> CDouble -> > IO CDouble > > that returns a random value parameterized by the two CDoubles. clearly > this must happen in IO since the return value will be differ

[Haskell] randomgen for foreign random functions

2004-06-25 Thread Hal Daume III
Hi All -- Say I have a foreign function: foreign import ccall "statistical_c.h gengam" c_gengam :: CDouble -> CDouble -> IO CDouble that returns a random value parameterized by the two CDoubles. clearly this must happen in IO since the return value will be different each time, and some g