cron-0.7.1: Cron datatypes and Attoparsec parser
Copyright(c) Andrew Rademacher 2014
LicenseMIT
MaintainerAndrew Rademacher <andrewrademacher@gmail.com>
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.Cron.Schedule

Description

main :: IO ()
main = do
       ...
       tids <- execSchedule $ do
           addJob job1 "* * * * *"
           addJob job2 "0 * * * *"
       print tids
       ...

job1 :: IO ()
job1 = putStrLn "Job 1"

job2 :: IO ()
job2 = putStrLn "Job 2"
Synopsis

Documentation

data Job Source #

Scheduling Monad

Constructors

Job CronSchedule (IO ()) 

Instances

Instances details
Show Job Source # 
Instance details

Defined in System.Cron.Schedule

Methods

showsPrec :: Int -> Job -> ShowS #

show :: Job -> String #

showList :: [Job] -> ShowS #

forkJob :: Job -> IO ThreadId Source #

Start a job-runner thread that runs a job at appropriate intervals. Each time it is run, a new thread is forked for it, meaning that a single exception does not take down the scheduler.

newtype ScheduleError Source #

Constructors

ParseError String 

Instances

Instances details
Show ScheduleError Source # 
Instance details

Defined in System.Cron.Schedule

Monad m => MonadError ScheduleError (ScheduleT m) Source # 
Instance details

Defined in System.Cron.Schedule

newtype ScheduleT m a Source #

Constructors

ScheduleT 

Fields

Instances

Instances details
Monad m => MonadError ScheduleError (ScheduleT m) Source # 
Instance details

Defined in System.Cron.Schedule

Monad m => Applicative (ScheduleT m) Source # 
Instance details

Defined in System.Cron.Schedule

Methods

pure :: a -> ScheduleT m a #

(<*>) :: ScheduleT m (a -> b) -> ScheduleT m a -> ScheduleT m b #

liftA2 :: (a -> b -> c) -> ScheduleT m a -> ScheduleT m b -> ScheduleT m c #

(*>) :: ScheduleT m a -> ScheduleT m b -> ScheduleT m b #

(<*) :: ScheduleT m a -> ScheduleT m b -> ScheduleT m a #

Functor m => Functor (ScheduleT m) Source # 
Instance details

Defined in System.Cron.Schedule

Methods

fmap :: (a -> b) -> ScheduleT m a -> ScheduleT m b #

(<$) :: a -> ScheduleT m b -> ScheduleT m a #

Monad m => Monad (ScheduleT m) Source # 
Instance details

Defined in System.Cron.Schedule

Methods

(>>=) :: ScheduleT m a -> (a -> ScheduleT m b) -> ScheduleT m b #

(>>) :: ScheduleT m a -> ScheduleT m b -> ScheduleT m b #

return :: a -> ScheduleT m a #

Monad m => MonadSchedule (ScheduleT m) Source # 
Instance details

Defined in System.Cron.Schedule

Methods

addJob :: IO () -> Text -> ScheduleT m () Source #

class MonadSchedule m where Source #

Methods

addJob :: IO () -> Text -> m () Source #

Instances

Instances details
Monad m => MonadSchedule (ScheduleT m) Source # 
Instance details

Defined in System.Cron.Schedule

Methods

addJob :: IO () -> Text -> ScheduleT m () Source #

execSchedule :: Schedule () -> IO [ThreadId] Source #

Schedule all of the jobs to run at appropriate intervals. Each job that is launched gets a scheduling thread to itself. Each time a scheduling thread launches a job, the job is forked onto a new thread. This means that if a job throws an excpetion in IO, its thread will be killed, but it will continue to be scheduled in the future.