on master help sign in
Follow hlint suggestion: use <$>.
a08dc15Phil de Joux
.hlint.yaml+2−3
@@ -2,12 +2,11 @@
2- ignore: {name: "Eta reduce"} # 6 hints
2- ignore: {name: "Eta reduce"} # 6 hints
3- ignore: {name: "Move brackets to avoid $"} # 19 hints
3- ignore: {name: "Move brackets to avoid $"} # 19 hints
4- ignore: {name: "Redundant $"} # 21 hints
4- ignore: {name: "Redundant $"} # 21 hints
5−- ignore: {name: "Redundant bracket"} # 119 hints
5+- ignore: {name: "Redundant bracket"} # 118 hints
6- ignore: {name: "Redundant if"} # 1 hint
6- ignore: {name: "Redundant if"} # 1 hint
7- ignore: {name: "Redundant lambda"} # 1 hint
7- ignore: {name: "Redundant lambda"} # 1 hint
8- ignore: {name: "Replace case with fromMaybe"} # 2 hints
8- ignore: {name: "Replace case with fromMaybe"} # 2 hints
9−- ignore: {name: "Use <$>"} # 6 hints
9+- ignore: {name: "Use asks"} # 13 hints
10−- ignore: {name: "Use asks"} # 12 hints
11- ignore: {name: "Use lambda-case"} # 5 hints
10- ignore: {name: "Use lambda-case"} # 5 hints
12- ignore: {name: "Use newtype instead of data"} # 1 hint
11- ignore: {name: "Use newtype instead of data"} # 1 hint
13- ignore: {name: "Use null"} # 3 hints
12- ignore: {name: "Use null"} # 3 hints
src/OddJobs/ConfigBuilder.hs+1−1
@@ -232,7 +232,7 @@ defaultDynamicJobTypes :: TableName
232 -> PGS.Query
232 -> PGS.Query
233 -> AllJobTypes
233 -> AllJobTypes
234defaultDynamicJobTypes tname jobTypeSql = AJTSql $ \conn -> do
234defaultDynamicJobTypes tname jobTypeSql = AJTSql $ \conn -> do
235− fmap (DL.map ((fromMaybe "(unknown)") . fromOnly)) $ PGS.query conn ("select distinct(" <> jobTypeSql <> ") from ? order by 1 nulls last") (Only tname)
235+ DL.map (fromMaybe "(unknown)" . fromOnly) <$> PGS.query conn ("select distinct(" <> jobTypeSql <> ") from ? order by 1 nulls last") (Only tname)
236
236
237-- | This makes __two important assumptions__. First, this /assumes/ that jobs
237-- | This makes __two important assumptions__. First, this /assumes/ that jobs
238-- in your app are represented by a sum-type. For example:
238-- in your app are represented by a sum-type. For example:
src/OddJobs/Endpoints.hs+1−1
@@ -188,7 +188,7 @@ filterResults cfg@UIConfig{uicfgJobToHtml, uicfgDbPool} Env{..} mFilter = do
188 <$> (filterJobs cfg conn filters)
188 <$> (filterJobs cfg conn filters)
189 <*> (countJobs cfg conn filters{ filterStatuses = [Job.Locked] })
189 <*> (countJobs cfg conn filters{ filterStatuses = [Job.Locked] })
190 t <- liftIO getCurrentTime
190 t <- liftIO getCurrentTime
191− js <- liftIO $ fmap (DL.zip jobs) $ uicfgJobToHtml jobs
191+ js <- liftIO (DL.zip jobs <$> uicfgJobToHtml jobs)
192 allJobTypes <- readIORef envJobTypesRef
192 allJobTypes <- readIORef envJobTypesRef
193 let navHtml = Web.sideNav envRoutes allJobTypes [] t filters
193 let navHtml = Web.sideNav envRoutes allJobTypes [] t filters
194 bodyHtml = Web.resultsPanel envRoutes t filters js runningCount
194 bodyHtml = Web.resultsPanel envRoutes t filters js runningCount
src/OddJobs/Job.hs+4−4
@@ -168,7 +168,7 @@ logCallbackErrors jid msg action = catchAny action $ \e -> log LevelError $ LogT
168
168
169instance HasJobRunner RunnerM where
169instance HasJobRunner RunnerM where
170 getPollingInterval = cfgPollingInterval . envConfig <$> ask
170 getPollingInterval = cfgPollingInterval . envConfig <$> ask
171− onJobFailed = do { env <- ask; pure (cfgOnJobFailed (envConfig env)) }
171+ onJobFailed = cfgOnJobFailed . envConfig <$> ask
172 onJobSuccess job = do
172 onJobSuccess job = do
173 fn <- cfgOnJobSuccess . envConfig <$> ask
173 fn <- cfgOnJobSuccess . envConfig <$> ask
174 logCallbackErrors (jobId job) "onJobSuccess" $ liftIO $ fn job
174 logCallbackErrors (jobId job) "onJobSuccess" $ liftIO $ fn job
@@ -338,7 +338,7 @@ runJobNowIO conn tname jid = do
338-- and somehow send an uninterruptibleCancel to that thread.
338-- and somehow send an uninterruptibleCancel to that thread.
339unlockJobIO :: Connection -> TableName -> JobId -> IO (Maybe Job)
339unlockJobIO :: Connection -> TableName -> JobId -> IO (Maybe Job)
340unlockJobIO conn tname jid = do
340unlockJobIO conn tname jid = do
341− fmap listToMaybe $ PGS.query conn q (tname, Retry, jid, In [Locked])
341+ listToMaybe <$> PGS.query conn q (tname, Retry, jid, In [Locked])
342 where
342 where
343 q = "update ? set status=?, run_at=now(), locked_at=null, locked_by=null where id=? and status in ? returning " <> concatJobDbColumns
343 q = "update ? set status=?, run_at=now(), locked_at=null, locked_by=null where id=? and status in ? returning " <> concatJobDbColumns
344
344
@@ -351,7 +351,7 @@ updateJobHelper :: TableName
351 -> (Status, [Status], Maybe UTCTime, JobId)
351 -> (Status, [Status], Maybe UTCTime, JobId)
352 -> IO (Maybe Job)
352 -> IO (Maybe Job)
353updateJobHelper tname conn (newStatus, existingStates, mRunAt, jid) =
353updateJobHelper tname conn (newStatus, existingStates, mRunAt, jid) =
354− fmap listToMaybe $ PGS.query conn q (tname, newStatus, runAt, jid, PGS.In existingStates)
354+ listToMaybe <$> PGS.query conn q (tname, newStatus, runAt, jid, PGS.In existingStates)
355 where
355 where
356 q = "update ? set attempts=0, status=?, run_at=? where id=? and status in ? returning " <> concatJobDbColumns
356 q = "update ? set attempts=0, status=?, run_at=? where id=? and status in ? returning " <> concatJobDbColumns
357 runAt = case mRunAt of
357 runAt = case mRunAt of
@@ -714,5 +714,5 @@ fetchAllJobRunners :: (MonadIO m)
714 => UIConfig
714 => UIConfig
715 -> m [JobRunnerName]
715 -> m [JobRunnerName]
716fetchAllJobRunners UIConfig{uicfgTableName, uicfgDbPool} = liftIO $ withResource uicfgDbPool $ \conn -> do
716fetchAllJobRunners UIConfig{uicfgTableName, uicfgDbPool} = liftIO $ withResource uicfgDbPool $ \conn -> do
717− fmap (mapMaybe fromOnly) $ PGS.query conn "select distinct locked_by from ?" (Only uicfgTableName)
717+ mapMaybe fromOnly <$> PGS.query conn "select distinct locked_by from ?" (Only uicfgTableName)
718
718