Hlint: Error: Redundant do

This commit is contained in:
marko.kocic 2009-09-22 12:08:28 +00:00
parent 8fdd28d446
commit 2855fe9e0a
3 changed files with 10 additions and 10 deletions

View File

@ -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 "%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 " %-30s %15s" acct (printf "$%s" amount' :: String)
putStrLn $ printf " %s\n" baseacct putStrLn $ printf " %s\n" baseacct
print_ledger_txn True _ record = do print_ledger_txn True _ record =
hPutStrLn stderr $ printf "ignoring %s" $ show record hPutStrLn stderr $ printf "ignoring %s" $ show record
print_ledger_txn _ _ _ = return () print_ledger_txn _ _ _ = return ()

View File

@ -72,7 +72,7 @@ parseLedgerFile t f = liftIO (readFile f) >>= parseLedger t f
-- the current (local) time to calculate any unfinished timelog sessions, -- the current (local) time to calculate any unfinished timelog sessions,
-- we pass it in for repeatability. -- we pass it in for repeatability.
parseLedger :: LocalTime -> FilePath -> String -> ErrorT String IO RawLedger parseLedger :: LocalTime -> FilePath -> String -> ErrorT String IO RawLedger
parseLedger reftime inname intxt = do parseLedger reftime inname intxt =
case runParser ledgerFile emptyCtx inname intxt of case runParser ledgerFile emptyCtx inname intxt of
Right m -> liftM (rawLedgerConvertTimeLog reftime) $ m `ap` (return rawLedgerEmpty) Right m -> liftM (rawLedgerConvertTimeLog reftime) $ m `ap` (return rawLedgerEmpty)
Left err -> throwError $ show err Left err -> throwError $ show err
@ -115,7 +115,7 @@ ledgerInclude = do many1 spacenonewline
case runParser ledgerFile outerState filename contents of case runParser ledgerFile outerState filename contents of
Right l -> l `catchError` (throwError . (inIncluded ++)) Right l -> l `catchError` (throwError . (inIncluded ++))
Left perr -> throwError $ inIncluded ++ show perr 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 where leftError err = return $ Left $ currentPos ++ whileReading ++ show err
currentPos = show outerPos currentPos = show outerPos
whileReading = " reading " ++ show filename ++ ":\n" whileReading = " reading " ++ show filename ++ ":\n"

View File

@ -285,7 +285,7 @@ tests = [
) )
] ]
,"accountnames" ~: do ,"accountnames" ~:
accountnames ledger7 `is` accountnames ledger7 `is`
["assets","assets:cash","assets:checking","assets:saving","equity","equity:opening balances", ["assets","assets:cash","assets:checking","assets:saving","equity","equity:opening balances",
"expenses","expenses:food","expenses:food:dining","expenses:phone","expenses:vacation", "expenses","expenses:food","expenses:food:dining","expenses:phone","expenses:vacation",
@ -487,14 +487,14 @@ tests = [
Right e' -> (pamount $ last $ ltpostings e') Right e' -> (pamount $ last $ ltpostings e')
Left _ -> error "should not happen") Left _ -> error "should not happen")
,"cacheLedger" ~: do ,"cacheLedger" ~:
length (Map.keys $ accountmap $ cacheLedger [] rawledger7) `is` 15 length (Map.keys $ accountmap $ cacheLedger [] rawledger7) `is` 15
,"canonicaliseAmounts" ~: ,"canonicaliseAmounts" ~:
"use the greatest precision" ~: do "use the greatest precision" ~:
rawLedgerPrecisions (canonicaliseAmounts False $ rawLedgerWithAmounts ["1","2.00"]) `is` [2,2] 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}] commodities ledger7 `is` [Commodity {symbol="$", side=L, spaced=False, comma=False, precision=2}]
,"dateSpanFromOpts" ~: do ,"dateSpanFromOpts" ~: do
@ -539,7 +539,7 @@ tests = [
[clockin future ""] [clockin future ""]
[printf "%s-%s" futurestr futurestr] [printf "%s-%s" futurestr futurestr]
,"expandAccountNames" ~: do ,"expandAccountNames" ~:
expandAccountNames ["assets:cash","assets:checking","expenses:vacation"] `is` expandAccountNames ["assets:cash","assets:checking","expenses:vacation"] `is`
["assets","assets:cash","assets:checking","expenses","expenses:vacation"] ["assets","assets:cash","assets:checking","expenses","expenses:vacation"]
@ -623,7 +623,7 @@ tests = [
r <- rawLedgerFromString "" -- don't know how to get it from ledgerFile 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 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 parseWithCtx emptyCtx ledgerHistoricalPrice price1_str `parseis` price1
,"ledgerTransaction" ~: do ,"ledgerTransaction" ~: do
@ -642,7 +642,7 @@ tests = [
assertBool "ledgeraccountname rejects an empty leading component" (isLeft $ parsewith ledgeraccountname ":b:c") assertBool "ledgeraccountname rejects an empty leading component" (isLeft $ parsewith ledgeraccountname ":b:c")
assertBool "ledgeraccountname rejects an empty trailing component" (isLeft $ parsewith ledgeraccountname "a:b:") assertBool "ledgeraccountname rejects an empty trailing component" (isLeft $ parsewith ledgeraccountname "a:b:")
,"ledgerposting" ~: do ,"ledgerposting" ~:
parseWithCtx emptyCtx ledgerposting rawposting1_str `parseis` rawposting1 parseWithCtx emptyCtx ledgerposting rawposting1_str `parseis` rawposting1
,"parsedate" ~: do ,"parsedate" ~: do