hi, i have been trying to learn haskell and i would like to translate the following object-oriented pseudo-code into working haskell code but i'm stumped on how to write the next function in the haskell code. any help is appreciated.
<br><br>class Random<br>...<br>end<br><br>ran = Random.new(300)<br>ran.next() <- this call generates a random number<br>ran.next() <- this one generates a different random number<br><br><br>so far what i have in haskell is:
<br><br>data Random = Ran Int Int<br>next :: Random->Int <- i have no idea how to write the next function that would give me the desired effect<br> because the object in the object-oriented code can remember how many times 'next'
<br> was called and i would like to do the same for 'ran' in the haskell code.<br>ran = Ran 300 0<br>next ran <- this generates a random number<br>next ran <- this generates another random number but since
<br> haskell is purely functional it is going to be the same as from <br> the previous call of 'next' which is not what i want<br>