The time difference in the response function (feelings) in Yampa

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?

+7
source share
1 answer

I would think that the reason why reactivate does not calculate the time delta is because it will hard code one particular concept of time. Imagine that you want to simulate a portfolio risk over a ten-year period or something like that, and your delta time resolution should be in one day. That being said, I agree that Ioref looks like a hack, although I used the same technique in my code.

+1
source

All Articles