I am trying to run an "infinite" simulation, printing the results of each step.
There's a function nextFrameR
which takes an input Map
and steps forward the simulation to return an output Map
, and then there's a render_
function which takes an input Map
and prints some things to stdout
, returning the input Map
(so that I can use iterate
or something like it).
I'm really struggling to put all these pieces together as am relatively new to Haskell. I found this answer extremely interesting but am not sure how to put it directly into practice due to the combination of the two functions (I have tried playing with liftM2
and iterate
).
The type signatures are as follows:
nextFrameR :: Map -> IO Map
render_ :: Map -> IO Map -- originally Map -> IO ()
I'm not really sure where to go from here, I can do something like:
(iterate (>>= nextFrameR) initialMap) :: [IO Map]
But that just gives me an (infinite?) list of frames (I think), which is great, it just doesn't let me print them as I don't know how to combine the rendering function in there.