readability cleanups

This commit is contained in:
Simon Michael 2011-08-28 22:16:58 +00:00
parent 6a61c96481
commit 9aaf489a38
2 changed files with 18 additions and 18 deletions

View File

@ -162,19 +162,20 @@ accountsReportItemAsText opts format (_, accountName, depth, Mixed amounts) =
formatAccountsReportItem :: ReportOpts -> Maybe AccountName -> Int -> Amount -> [FormatString] -> String formatAccountsReportItem :: ReportOpts -> Maybe AccountName -> Int -> Amount -> [FormatString] -> String
formatAccountsReportItem _ _ _ _ [] = "" formatAccountsReportItem _ _ _ _ [] = ""
formatAccountsReportItem opts accountName depth amount (f:fs) = s ++ (formatAccountsReportItem opts accountName depth amount fs) formatAccountsReportItem opts accountName depth amount (fmt:fmts) =
s ++ (formatAccountsReportItem opts accountName depth amount fs)
where where
s = case f of s = case fmt of
FormatLiteral l -> l FormatLiteral l -> l
FormatField leftJustified min max field -> formatAccount opts accountName depth amount leftJustified min max field FormatField ljust min max field -> formatField opts accountName depth amount ljust min max field
formatAccount :: ReportOpts -> Maybe AccountName -> Int -> Amount -> Bool -> Maybe Int -> Maybe Int -> Field -> String formatField :: ReportOpts -> Maybe AccountName -> Int -> Amount -> Bool -> Maybe Int -> Maybe Int -> Field -> String
formatAccount opts accountName depth balance leftJustified min max field = case field of formatField opts accountName depth balance ljust min max field = case field of
Format.Account -> formatValue leftJustified min max a Format.Account -> formatValue ljust min max a
DepthSpacer -> case min of Format.DepthSpacer -> case min of
Just m -> formatValue leftJustified Nothing max $ replicate (depth * m) ' ' Just m -> formatValue ljust Nothing max $ replicate (depth * m) ' '
Nothing -> formatValue leftJustified Nothing max $ replicate depth ' ' Nothing -> formatValue ljust Nothing max $ replicate depth ' '
Total -> formatValue leftJustified min max $ showAmountWithoutPrice balance Format.Total -> formatValue ljust min max $ showAmountWithoutPrice balance
_ -> "" _ -> ""
where where
a = maybe "" (accountNameDrop (drop_ opts)) accountName a = maybe "" (accountNameDrop (drop_ opts)) accountName

View File

@ -26,8 +26,7 @@ data Field =
data FormatString = data FormatString =
FormatLiteral String FormatLiteral String
| FormatField | FormatField Bool -- Left justified ?
Bool -- Left justified
(Maybe Int) -- Min width (Maybe Int) -- Min width
(Maybe Int) -- Max width (Maybe Int) -- Max width
Field -- Field Field -- Field