Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/System/Cron/Schedule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module System.Cron.Schedule
, runScheduleT

, execSchedule
, jobsToSchedule
) where


Expand Down Expand Up @@ -93,6 +94,8 @@ newtype ScheduleT m a = ScheduleT { unSchedule :: StateT Jobs (ExceptT ScheduleE
, MonadError ScheduleError
)

instance MonadTrans ScheduleT where
lift = ScheduleT . lift . lift

-------------------------------------------------------------------------------
runSchedule :: Schedule a -> Either ScheduleError (a, [Job])
Expand All @@ -119,6 +122,10 @@ instance (Monad m) => MonadSchedule (ScheduleT m) where
-- Monitoring engine
-------------------------------------------------------------------------------

-- | Utility function to initialize a schedule from a set of jobs.
jobsToSchedule :: [Job] -> Schedule ()
jobsToSchedule jobs = forM_ jobs $ \(Job schedule action) -> do
addJob action (serializeCronSchedule schedule)

-- | Schedule all of the jobs to run at appropriate intervals. Each
-- job that is launched gets a scheduling thread to itself. Each
Expand Down