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.
class Random
...
end
ran = Random.new(300)
ran.next() <- this call generates a random number
ran.next() <- this one generates a different random number
so far what i have in haskell is:
data Random = Ran Int Int
next :: Random->Int <- i have no idea how to write the next function that would give me the desired effect
because the object in the object-oriented code can remember how many times 'next'
was called and i would like to do the same for 'ran' in the haskell code.
ran = Ran 300 0
next ran <- this generates a random number
next ran <- this generates another random number but since
haskell is purely functional it is going to be the same as from
the previous call of 'next' which is not what i want