-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
The standard way to wait in the Haskell IO monad is threadDelay. This works reasonably well, but the type of this action is awkward – integer time in magic-number-micro–seconds. Surely there should be a variant of this with a properly-typed time argument. Since threadDelay is in base, but no suitable time-type, it would seem sensible to put it in a library that defines such a time type – like thyme!
I've just written the following wrapper for my dynamic-plot project (which still uses time though I think I want to switch to thyme soon):
waitTill :: UTCTime -> IO ()
waitTill t = do
tnow <- getCurrentTime
threadDelay . max 0 . round $ diffUTCTime t tnow
* 1e+6 -- threadDelay ticks in microsecondsAre there any arguments against adding a module with such “waiter-actions” to thyme?
Metadata
Metadata
Assignees
Labels
No labels