aboutsummaryrefslogtreecommitdiff
path: root/src/F2Md
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-05-30 16:22:44 +1000
committerYuchen Pei <hi@ypei.me>2022-05-30 16:22:44 +1000
commitc96f8f6c820d43a55388f0307f3a6de9471ebb10 (patch)
treed28b4a77c03a4bb50b9ee0ea5d87074ace254e60 /src/F2Md
parent231b58693759be1174a3866e469f170387c22376 (diff)
linting
Diffstat (limited to 'src/F2Md')
-rw-r--r--src/F2Md/Config.hs4
-rw-r--r--src/F2Md/Export.hs2
-rw-r--r--src/F2Md/Import.hs23
-rw-r--r--src/F2Md/Utils.hs2
4 files changed, 14 insertions, 17 deletions
diff --git a/src/F2Md/Config.hs b/src/F2Md/Config.hs
index 33380fa..c952d09 100644
--- a/src/F2Md/Config.hs
+++ b/src/F2Md/Config.hs
@@ -78,10 +78,10 @@ updateLastUpdated' path feed msgs =
HM.insert
(fuUrl feed)
(utcToZonedTime (zonedTimeZone $ mDate $ head msgs) . maximum $
- (zonedTimeToUTC . mDate) <$> msgs)
+ zonedTimeToUTC . mDate <$> msgs)
decoded
updateLastUpdated :: FilePath -> [FeedUserdata] -> [[Message]] -> IO ()
updateLastUpdated path feeds feedMsgs = do
- mapM_ (\(feed, msgs) -> updateLastUpdated' path feed msgs)
+ mapM_ (uncurry (updateLastUpdated' path))
(zip feeds feedMsgs)
diff --git a/src/F2Md/Export.hs b/src/F2Md/Export.hs
index b06155c..d3ed45a 100644
--- a/src/F2Md/Export.hs
+++ b/src/F2Md/Export.hs
@@ -35,7 +35,7 @@ import System.FilePath
formatMessage :: Message -> Text
formatMessage (Message from subject date messageId body _) =
- "MIME-Version: 1.0\n" <> "Date: " <> (T.pack $ show date) <> "\nSubject: " <> subject <>
+ "MIME-Version: 1.0\n" <> "Date: " <> T.pack (show date) <> "\nSubject: " <> subject <>
"\nFrom: " <> from <> "\nMessage-ID: " <> messageId <>
"\nContent-Type: text/html" <> "\n\n" <> body
diff --git a/src/F2Md/Import.hs b/src/F2Md/Import.hs
index 7c8110c..80dfa54 100644
--- a/src/F2Md/Import.hs
+++ b/src/F2Md/Import.hs
@@ -39,17 +39,16 @@ import Data.Generics
import Text.RSS.Syntax hiding (RSSItem)
import Data.XML.Types
import Text.Feed.Import
-import Text.Feed.Types
import F2Md.Types
import Crypto.Hash
toMessagesFromUrl :: Text -> Maybe ZonedTime -> IO [Message]
toMessagesFromUrl url after = do
- feed <- parseFeedString <$> (fetchFeed $ T.unpack url)
+ feed <- parseFeedString <$> fetchFeed (T.unpack url)
case feed of
Nothing -> return []
Just feed' -> return $
- sortOn (\msg -> zonedTimeToUTC (mDate msg)) $ catMaybes $
+ sortOn (zonedTimeToUTC . mDate) $ catMaybes $
toMessage' after (toFeedMetadata feed' url) <$> getFeedItems feed'
wgetCommand :: String
@@ -76,12 +75,12 @@ toMessage (FeedMetadata title author home url) item =
body
url
where body =
- (formatBody (getItemLink item) (getItemEnclosure item) $
+ formatBody (getItemLink item) (getItemEnclosure item) $
(getItemContent item) `orElse` (getItemContent' item) `orElse`
- (getItemDescription item))
+ (getItemDescription item)
messageId =
- "<" <> (T.pack $ show $ hashWith MD5 (encodeUtf8 body)) <> "@" <>
- (T.map hyphenateNonAlNum url) <> ".gnu" <> ">"
+ "<" <> T.pack (show $ hashWith MD5 (encodeUtf8 body)) <> "@" <>
+ T.map hyphenateNonAlNum url <> ".gnu" <> ">"
getItemAuthor' :: Item -> Maybe Text
@@ -92,8 +91,7 @@ getItemAuthor' item = case getItemAuthor item of
getItemContent' :: Item -> Maybe Text
getItemContent' (RSSItem item) =
- (fmap (T.concat . elementText) . listToMaybe .
- filter (\e -> namePrefix (elementName e) == Just "content"))
+ (fmap (T.concat . elementText) . find (\e -> namePrefix (elementName e) == Just "content"))
$ rssItemOther item
getItemContent' _ = Nothing
@@ -110,13 +108,12 @@ formatBody link encl desc =
Just (url, Just ty, Just len) ->
urlPt url <> " (" <> ty <> ", " <> lenPt len <> ")\n\n"
where urlPt url = "Enclosure: <" <> url <> ">"
- lenPt len = (T.pack $ show len) <> " bytes"
+ lenPt len = T.pack (show len) <> " bytes"
in
- linkText <> enclText <> (fromMaybe "" desc)
+ linkText <> enclText <> fromMaybe "" desc
toFeedMetadata :: Feed -> Text -> FeedMetadata
-toFeedMetadata feed url =
- FeedMetadata (getFeedTitle feed) (getFeedAuthor feed) (getFeedHome feed) url
+toFeedMetadata feed = FeedMetadata (getFeedTitle feed) (getFeedAuthor feed) (getFeedHome feed)
hyphenateNonAlNum :: Char -> Char
hyphenateNonAlNum c
diff --git a/src/F2Md/Utils.hs b/src/F2Md/Utils.hs
index 25bf63a..33abe00 100644
--- a/src/F2Md/Utils.hs
+++ b/src/F2Md/Utils.hs
@@ -28,5 +28,5 @@ expandPath path =
let (pre, post) = break (=='/') path in
case pre of
"~" -> (++ post) <$> getHomeDirectory
- '~' : user -> (++ post) <$> homeDirectory <$> getUserEntryForName user
+ '~' : user -> (++ post) . homeDirectory <$> getUserEntryForName user
_ -> return path