Skip to content

Commit

Permalink
Use do notation, to match the theme
Browse files Browse the repository at this point in the history
  • Loading branch information
The1Penguin committed Oct 10, 2024
1 parent ca0a56b commit bd4a389
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,17 @@ removeOldLogs :: ( MonadIO m
, MonadLog (WithTimestamp (Doc ann)) m
, MonadReader Config m
) => m ()
removeOldLogs =
liftIO getCurrentTime >>= \now ->
asks _cLogAge >>= \offset ->
asks _cLogPath >>= \path ->
liftIO (listDirectory path) >>=
mapM (\s -> liftIO (getAccessTime s) <&> (s,)) . fmap ((path ++ "/") ++) >>=
fmap (fmap fst) . filterM (pure . (<= (now & _utctDay %~ (.-^ offset))) . toThyme . snd) >>= \files ->
removeOldLogs = do
now <- liftIO getCurrentTime
offset <- asks _cLogAge
path <- asks _cLogPath
files <- liftIO (listDirectory path) >>=
mapM (\s -> liftIO (getAccessTime s) <&> (s,)) . fmap ((path ++ "/") ++) >>=
filterM (pure . (<= (now & _utctDay %~ (.-^ offset))) . toThyme . snd) <&>
fmap fst
timestamp ("Removing the following files:" <+> prettyList files) >>=
logMessage >>
liftIO (mapM_ removeFile files)
logMessage >>
liftIO (mapM_ removeFile files)

update
:: ( MonadIO m
Expand Down

0 comments on commit bd4a389

Please sign in to comment.