From 2855fe9e0abea187072e36e03a4fa01aac18ede0 Mon Sep 17 00:00:00 2001 From: "marko.kocic" Date: Tue, 22 Sep 2009 12:08:28 +0000 Subject: [PATCH] Hlint: Error: Redundant do --- Commands/Convert.hs | 2 +- Ledger/Parse.hs | 4 ++-- Tests.hs | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Commands/Convert.hs b/Commands/Convert.hs index 3a04e865e..839041388 100644 --- a/Commands/Convert.hs +++ b/Commands/Convert.hs @@ -95,7 +95,7 @@ print_ledger_txn debug (baseacct,fieldpositions,rules) record@(_:_:_:_:_:[]) = d putStrLn $ printf "%s%s %s" (fixdate date) (if not (null number) then printf " (%s)" number else "") desc putStrLn $ printf " %-30s %15s" acct (printf "$%s" amount' :: String) putStrLn $ printf " %s\n" baseacct -print_ledger_txn True _ record = do +print_ledger_txn True _ record = hPutStrLn stderr $ printf "ignoring %s" $ show record print_ledger_txn _ _ _ = return () diff --git a/Ledger/Parse.hs b/Ledger/Parse.hs index f1d5b585c..4e316b8ba 100644 --- a/Ledger/Parse.hs +++ b/Ledger/Parse.hs @@ -72,7 +72,7 @@ parseLedgerFile t f = liftIO (readFile f) >>= parseLedger t f -- the current (local) time to calculate any unfinished timelog sessions, -- we pass it in for repeatability. parseLedger :: LocalTime -> FilePath -> String -> ErrorT String IO RawLedger -parseLedger reftime inname intxt = do +parseLedger reftime inname intxt = case runParser ledgerFile emptyCtx inname intxt of Right m -> liftM (rawLedgerConvertTimeLog reftime) $ m `ap` (return rawLedgerEmpty) Left err -> throwError $ show err @@ -115,7 +115,7 @@ ledgerInclude = do many1 spacenonewline case runParser ledgerFile outerState filename contents of Right l -> l `catchError` (throwError . (inIncluded ++)) Left perr -> throwError $ inIncluded ++ show perr - where readFileE outerPos filename = ErrorT $ do liftM Right (readFile filename) `catch` leftError + where readFileE outerPos filename = ErrorT $ liftM Right (readFile filename) `catch` leftError where leftError err = return $ Left $ currentPos ++ whileReading ++ show err currentPos = show outerPos whileReading = " reading " ++ show filename ++ ":\n" diff --git a/Tests.hs b/Tests.hs index de74afd69..b6d4a48e4 100644 --- a/Tests.hs +++ b/Tests.hs @@ -285,7 +285,7 @@ tests = [ ) ] - ,"accountnames" ~: do + ,"accountnames" ~: accountnames ledger7 `is` ["assets","assets:cash","assets:checking","assets:saving","equity","equity:opening balances", "expenses","expenses:food","expenses:food:dining","expenses:phone","expenses:vacation", @@ -487,14 +487,14 @@ tests = [ Right e' -> (pamount $ last $ ltpostings e') Left _ -> error "should not happen") - ,"cacheLedger" ~: do + ,"cacheLedger" ~: length (Map.keys $ accountmap $ cacheLedger [] rawledger7) `is` 15 ,"canonicaliseAmounts" ~: - "use the greatest precision" ~: do + "use the greatest precision" ~: rawLedgerPrecisions (canonicaliseAmounts False $ rawLedgerWithAmounts ["1","2.00"]) `is` [2,2] - ,"commodities" ~: do + ,"commodities" ~: commodities ledger7 `is` [Commodity {symbol="$", side=L, spaced=False, comma=False, precision=2}] ,"dateSpanFromOpts" ~: do @@ -539,7 +539,7 @@ tests = [ [clockin future ""] [printf "%s-%s" futurestr futurestr] - ,"expandAccountNames" ~: do + ,"expandAccountNames" ~: expandAccountNames ["assets:cash","assets:checking","expenses:vacation"] `is` ["assets","assets:cash","assets:checking","expenses","expenses:vacation"] @@ -623,7 +623,7 @@ tests = [ r <- rawLedgerFromString "" -- don't know how to get it from ledgerFile assertBool "ledgerFile parsing an empty file should give an empty ledger" $ null $ ledger_txns r - ,"ledgerHistoricalPrice" ~: do + ,"ledgerHistoricalPrice" ~: parseWithCtx emptyCtx ledgerHistoricalPrice price1_str `parseis` price1 ,"ledgerTransaction" ~: do @@ -642,7 +642,7 @@ tests = [ assertBool "ledgeraccountname rejects an empty leading component" (isLeft $ parsewith ledgeraccountname ":b:c") assertBool "ledgeraccountname rejects an empty trailing component" (isLeft $ parsewith ledgeraccountname "a:b:") - ,"ledgerposting" ~: do + ,"ledgerposting" ~: parseWithCtx emptyCtx ledgerposting rawposting1_str `parseis` rawposting1 ,"parsedate" ~: do