From ae4cdbc0662d67d3d325c8ab567e0d45a84413b3 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 28 Nov 2014 00:11:02 -0500 Subject: [PATCH] Fix hlint suggestions. --- src/Forward.hs | 4 ++-- src/Main.hs | 2 +- src/Report.hs | 32 ++++++++++++++------------------ 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Forward.hs b/src/Forward.hs index 7de53b8..3e9ad88 100644 --- a/src/Forward.hs +++ b/src/Forward.hs @@ -214,8 +214,8 @@ address_domain (Forward (Address addr) _) = domain_part addr domain_part :: String -> Maybe Domain domain_part address = case parts of - (_:domain:[]) -> Just domain - _ -> Nothing + [_,domain] -> Just domain + _ -> Nothing where parts = split "@" address diff --git a/src/Main.hs b/src/Main.hs index ab4d055..66d02a0 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -79,4 +79,4 @@ main = do where show_sql_error :: SqlError -> IO () show_sql_error se = hPutStrLn stderr $ - "SQL Error (" ++ (show $ seNativeError se) ++ "): " ++ (seErrorMsg se) + "SQL Error (" ++ show (seNativeError se) ++ "): " ++ (seErrorMsg se) diff --git a/src/Report.hs b/src/Report.hs index 5b38533..dd3ce4e 100644 --- a/src/Report.hs +++ b/src/Report.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE PatternGuards #-} - module Report ( report, report_tests ) @@ -13,6 +11,7 @@ import qualified Data.Set as Set ( map ) import Data.String.Utils ( join ) import Database.HDBC ( IConnection, + Statement, execute, prepare, sFetchAllRows') @@ -35,6 +34,17 @@ import MxList ( MxList(..) ) -- WARNING: Also defined in the "Forward" module. type Domain = String + +-- | We really want executeRaw here, but there's a bug: it will tell +-- us we can't fetch rows from the statement since it hasn't been +-- executed yet! +-- +my_executeRaw :: Statement -> IO [[Maybe String]] +my_executeRaw stmt = do + _ <- execute stmt [] + sFetchAllRows' stmt + + -- | Given a connection @conn@ and a @query@, return a list of domains -- found by executing @query@ on @conn. The @query@ is assumed to -- return only one column, containing domains. @@ -45,14 +55,7 @@ get_domain_list :: IConnection a -> IO [Domain] -- ^ The list of domains returned from @query@ get_domain_list conn query = do stmt <- prepare conn query - - -- We really want executeRaw here, but there's a bug: it will tell - -- us we can't fetch rows from the statement since it hasn't been - -- executed yet! - _ <- execute stmt [] - - -- rows :: [[Maybe String]] - rows <- sFetchAllRows' stmt + rows <- my_executeRaw stmt -- rows' :: [Maybe String] let rows' = map (listToMaybe . catMaybes) rows @@ -77,14 +80,7 @@ get_forward_list :: IConnection a -> IO [Forward] -- ^ A list of forwards returned from @query@ get_forward_list conn query = do stmt <- prepare conn query - - -- We really want executeRaw here, but there's a bug: it will tell - -- us we can't fetch rows from the statement since it hasn't been - -- executed yet! - _ <- execute stmt [] - - -- rows :: [[Maybe String]] - rows <- sFetchAllRows' stmt + rows <- my_executeRaw stmt -- forwards :: [Forward] let forwards = concatMap (strings_to_forwards . catMaybes) rows -- 2.43.2