I am studying Haskell and Yampa at the moment and asking a question about the response function.
reactimate :: IO a -- init -> (Bool -> IO (DTime, Maybe a)) -- sense -> (Bool -> b -> IO Bool) -- actuate -> SF ab -- signal function -> IO ()
As you can see in the type signature, part of the output for the sensation function is the time difference between the current and previous function calls. In the examples I saw, the time difference "manually" is calculated inside the meaning, using IORef to save the value of the previous call.
It seems strange that you need to track the time difference using an external state, why is this calculation not performed as a critical strike function? Is IORef a good way to handle this?
Asgar zigel
source share