module Daemon ( runDaemon ) where import Control.Concurrent (threadDelay) import Control.Monad (forever) import Daemon.Frequency runDaemon :: Frequency -> (() -> IO ()) -> IO () runDaemon frequency process = forever $ do process () threadDelay (sleepDelayMs frequency) sleepDelayMs :: Frequency -> Int sleepDelayMs Hourly = 1000000 * 60 * 60 sleepDelayMs Daily = (sleepDelayMs Hourly) * 24