From: Michael Orlitzky Date: Thu, 4 Jul 2013 01:01:47 +0000 (-0400) Subject: Replace necessary NoMonomorphism language pragma. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhalcyon.git;a=commitdiff_plain;h=cf0e5470657c80d2e4db116b309e8ca35b4136ad Replace necessary NoMonomorphism language pragma. Add an hlint makefile target and implement some suggestions. --- diff --git a/makefile b/makefile index 8bd7248..abe71a3 100644 --- a/makefile +++ b/makefile @@ -17,3 +17,9 @@ doc: runghc Setup.hs haddock --internal \ --executables \ --hyperlink-source + +hlint: + hlint --ignore="Use camelCase" \ + --ignore="Redundant bracket" \ + --color \ + src diff --git a/src/StringUtils.hs b/src/StringUtils.hs index f9d7dfc..52b1def 100644 --- a/src/StringUtils.hs +++ b/src/StringUtils.hs @@ -13,8 +13,8 @@ import Test.HUnit -- 3. etc. -- listify :: [String] -> [String] -listify items = - zipWith (++) list_numbers items +listify = + zipWith (++) list_numbers where list_numbers = map show_with_dot [1::Integer ..] show_with_dot x = (show x) ++ ". " diff --git a/src/Twitter/Http.hs b/src/Twitter/Http.hs index 112c2ea..c8b8e47 100644 --- a/src/Twitter/Http.hs +++ b/src/Twitter/Http.hs @@ -49,26 +49,23 @@ user_new_statuses_url username last_status_id = get_status :: Integer -> IO B.ByteString get_status status_id = do - let uri = (status_url status_id) - status <- (http_get uri) - return status + let uri = status_url status_id + http_get uri -- | Return's username's timeline. get_user_timeline :: String -> IO B.ByteString get_user_timeline username = do - let uri = (user_timeline_url username) - timeline <- (http_get uri) - return timeline + let uri = user_timeline_url username + http_get uri -- | Returns the JSON representing all of username's statuses that are -- newer than last_status_id. get_user_new_statuses :: String -> Integer -> IO B.ByteString get_user_new_statuses username last_status_id = do - let uri = (user_new_statuses_url username last_status_id) - new_statuses <- (http_get uri) - return new_statuses + let uri = user_new_statuses_url username last_status_id + http_get uri -- | Retrieve a URL, or crash. diff --git a/src/Twitter/Status.hs b/src/Twitter/Status.hs index ef4e103..6ff7e6c 100644 --- a/src/Twitter/Status.hs +++ b/src/Twitter/Status.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE NoMonomorphismRestriction #-} + -- | Functions and data for working with Twitter statuses. module Twitter.Status where @@ -5,7 +7,7 @@ where import Control.Applicative ((<$>), (<*>)) import Control.Monad (liftM) import Data.Aeson ((.:), FromJSON(..), Value(Object)) -import Data.Maybe (catMaybes, isJust) +import Data.Maybe (fromMaybe, mapMaybe, isJust) import Data.Monoid (mempty) import Data.String.Utils (join, splitWs) import Data.Text (pack) @@ -74,7 +76,7 @@ utc_time_to_rfc822 mtz utc = show_created_at :: Maybe TimeZone -> Status -> String show_created_at mtz = - (maybe "" id) . (fmap $ utc_time_to_rfc822 mtz) . created_at + (fromMaybe "") . (fmap $ utc_time_to_rfc822 mtz) . created_at -- | Returns a nicely-formatted String representing the given 'Status' -- object. @@ -121,7 +123,7 @@ parse_username word = -- | Parse all usernames of the form \@username from a status. parse_usernames_from_status :: Status -> [String] parse_usernames_from_status status = - catMaybes (map parse_username status_words) + mapMaybe parse_username status_words where status_words = splitWs (text status)