on master help sign in
Follow hlint suggestion: use <$>.
commita08dc158296a31650c9a19d405f45c4835c2754f authorPhil de Joux <philderbeast@gmail.com> dateSun 16 Oct 2022, 15:23 (4 years ago) parentd928131
4 files changed+8−9
.hlint.yaml+2−3 src/OddJobs/ConfigBuilder.hs+1−1 src/OddJobs/Endpoints.hs+1−1 src/OddJobs/Job.hs+4−4
.hlint.yaml+2−3
@@ -2,12 +2,11 @@
22- ignore: {name: "Eta reduce"} # 6 hints
33- ignore: {name: "Move brackets to avoid $"} # 19 hints
44- ignore: {name: "Redundant $"} # 21 hints
5−- ignore: {name: "Redundant bracket"} # 119 hints
5+- ignore: {name: "Redundant bracket"} # 118 hints
66- ignore: {name: "Redundant if"} # 1 hint
77- ignore: {name: "Redundant lambda"} # 1 hint
88- ignore: {name: "Replace case with fromMaybe"} # 2 hints
9−- ignore: {name: "Use <$>"} # 6 hints
10−- ignore: {name: "Use asks"} # 12 hints
9+- ignore: {name: "Use asks"} # 13 hints
1110- ignore: {name: "Use lambda-case"} # 5 hints
1211- ignore: {name: "Use newtype instead of data"} # 1 hint
1312- ignore: {name: "Use null"} # 3 hints
src/OddJobs/ConfigBuilder.hs+1−1
@@ -232,7 +232,7 @@ defaultDynamicJobTypes :: TableName
232232 -> PGS.Query
233233 -> AllJobTypes
234234defaultDynamicJobTypes 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)
236236
237237-- | This makes __two important assumptions__. First, this /assumes/ that jobs
238238-- 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
188188 <$> (filterJobs cfg conn filters)
189189 <*> (countJobs cfg conn filters{ filterStatuses = [Job.Locked] })
190190 t <- liftIO getCurrentTime
191− js <- liftIO $ fmap (DL.zip jobs) $ uicfgJobToHtml jobs
191+ js <- liftIO (DL.zip jobs <$> uicfgJobToHtml jobs)
192192 allJobTypes <- readIORef envJobTypesRef
193193 let navHtml = Web.sideNav envRoutes allJobTypes [] t filters
194194 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
168168
169169instance HasJobRunner RunnerM where
170170 getPollingInterval = cfgPollingInterval . envConfig <$> ask
171− onJobFailed = do { env <- ask; pure (cfgOnJobFailed (envConfig env)) }
171+ onJobFailed = cfgOnJobFailed . envConfig <$> ask
172172 onJobSuccess job = do
173173 fn <- cfgOnJobSuccess . envConfig <$> ask
174174 logCallbackErrors (jobId job) "onJobSuccess" $ liftIO $ fn job
@@ -338,7 +338,7 @@ runJobNowIO conn tname jid = do
338338-- and somehow send an uninterruptibleCancel to that thread.
339339unlockJobIO :: Connection -> TableName -> JobId -> IO (Maybe Job)
340340unlockJobIO 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])
342342 where
343343 q = "update ? set status=?, run_at=now(), locked_at=null, locked_by=null where id=? and status in ? returning " <> concatJobDbColumns
344344
@@ -351,7 +351,7 @@ updateJobHelper :: TableName
351351 -> (Status, [Status], Maybe UTCTime, JobId)
352352 -> IO (Maybe Job)
353353updateJobHelper 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)
355355 where
356356 q = "update ? set attempts=0, status=?, run_at=? where id=? and status in ? returning " <> concatJobDbColumns
357357 runAt = case mRunAt of
@@ -714,5 +714,5 @@ fetchAllJobRunners :: (MonadIO m)
714714 => UIConfig
715715 -> m [JobRunnerName]
716716fetchAllJobRunners 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)
718718