From: Michael Orlitzky Date: Sat, 13 Jul 2013 22:47:32 +0000 (-0400) Subject: Fix remaining hlint suggestions. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhalcyon.git;a=commitdiff_plain;h=d721869c5e7395c021cc79f40720bdb275d613d2 Fix remaining hlint suggestions. --- diff --git a/src/CommandLine.hs b/src/CommandLine.hs index db3b12d..0b081bc 100644 --- a/src/CommandLine.hs +++ b/src/CommandLine.hs @@ -150,7 +150,7 @@ set_heartbeat arg opts = do return opts { opt_heartbeat = new_heartbeat } set_help :: Options -> IO Options -set_help opts = do +set_help opts = return opts { opt_help = True } set_ignore_retweets :: Options -> IO Options @@ -211,19 +211,14 @@ parse_options = do heartbeat_errors :: IO [String] heartbeat_errors = do hb <- parse_heartbeat - if (isNothing hb) - then return ["\"heartbeat\" does not appear to be an integer."] - else return [] + return ["\"heartbeat\" does not appear to be an integer." | isNothing hb ] -- | Parse errors relating to the list of usernames. username_errors :: IO [String] username_errors = do argv <- getArgs let (_, usernames, _) = getOpt Permute options argv - - if (null usernames) - then return ["no usernames provided."] - else return [] + return [ "no usernames provided." | null usernames ] -- | Parse errors relating to the "To" address. @@ -231,9 +226,8 @@ to_errors :: IO [String] to_errors = do toaddr <- parse_to_address fromaddr <- parse_from_address - if (isNothing toaddr) && (isJust fromaddr) - then return ["\"from\" address specified without \"to\" address."] - else return [] + return ["\"from\" address specified without \"to\" address." + | (isNothing toaddr) && (isJust fromaddr) ] -- | Errors for the sendmail path argument. @@ -241,9 +235,7 @@ sendmail_path_errors :: IO [String] sendmail_path_errors = do sendmail <- parse_sendmail_path exists <- doesFileExist sendmail - if (not exists) - then return ["sendmail path does not exist"] - else return [] + return [ "sendmail path does not exist" | not exists ] -- | Parse errors relating to the "From" address. @@ -251,9 +243,8 @@ from_errors :: IO [String] from_errors = do toaddr <- parse_to_address fromaddr <- parse_from_address - if (isJust toaddr) && (isNothing fromaddr) - then return ["\"to\" address specified without \"from\" address."] - else return [] + return [ "\"to\" address specified without \"from\" address." + | (isJust toaddr) && (isNothing fromaddr) ] -- | Format an error message for printing. diff --git a/src/Mail.hs b/src/Mail.hs index 8c1f25c..db5673f 100644 --- a/src/Mail.hs +++ b/src/Mail.hs @@ -5,6 +5,7 @@ where import Control.Concurrent import Control.Exception (evaluate) +import Control.Monad (liftM) import Data.List (intercalate) import Data.Time (formatTime, getZonedTime) import System.Exit @@ -62,9 +63,9 @@ pad_left str n -- | Constructs a 'String' in RFC822 date format for the current -- date/time. rfc822_now :: IO String -rfc822_now = do - date <- getZonedTime - return $ formatTime defaultTimeLocale rfc822DateFormat date +rfc822_now = + liftM (formatTime defaultTimeLocale rfc822DateFormat) getZonedTime + @@ -100,7 +101,7 @@ sendmail sendmail_path message = do -- errors, and exit codes. This function pretty-prints one of those -- three-tuples. print_sendmail_result :: (String, String, ExitCode) -> IO () -print_sendmail_result (outs, errs, ec) = do +print_sendmail_result (outs, errs, ec) = case ec of ExitSuccess -> return () _ -> putStrLn $ concat ["Output: " ++ outs, diff --git a/src/Twitter/Http.hs b/src/Twitter/Http.hs index 6d055b9..3b83485 100644 --- a/src/Twitter/Http.hs +++ b/src/Twitter/Http.hs @@ -45,9 +45,10 @@ status_url status_id = -- "since_id" parameter tacked on. user_new_statuses_url :: String -> Integer -> String user_new_statuses_url username last_status_id = - concat [ user_timeline_url username, - "&since_id=" ++ (show last_status_id) ] - + url ++ "&since_id=" ++ since_id + where + url = user_timeline_url username + since_id = show last_status_id get_status :: Cfg -> Integer -> IO B.ByteString get_status cfg status_id = do diff --git a/src/Twitter/Status.hs b/src/Twitter/Status.hs index 191b8e8..0bc60fa 100644 --- a/src/Twitter/Status.hs +++ b/src/Twitter/Status.hs @@ -7,7 +7,7 @@ where import Control.Applicative ((<$>), (<*>)) import Control.Monad (liftM) import Data.Aeson ((.:), FromJSON(..), Value(Object)) -import Data.Maybe (fromMaybe, mapMaybe, isJust) +import Data.Maybe (mapMaybe, isJust) import Data.Monoid (mempty) import Data.String.Utils (join, splitWs) import Data.Text (pack) @@ -79,7 +79,7 @@ utc_time_to_rfc822 mtz utc = show_created_at :: Maybe TimeZone -> Status -> String show_created_at mtz = - (fromMaybe "") . (fmap $ utc_time_to_rfc822 mtz) . created_at + (maybe "" (utc_time_to_rfc822 mtz)) . created_at -- | Returns a nicely-formatted String representing the given 'Status' -- object.