web: make hledger[-lib] compatible with all of yesod's language extensions

Useful when building all of hledger-web at once.
This commit is contained in:
Simon Michael 2012-11-14 17:25:02 +00:00
parent ef73894889
commit 5b9c5459be
10 changed files with 17 additions and 14 deletions

View File

@ -26,7 +26,7 @@ import Hledger.Utils
instance Show Account where
show Account{..} = printf "Account %s (boring:%s, ebalance:%s, ibalance:%s)"
aname
(if aboring then "y" else "n")
(if aboring then "y" else "n" :: String)
(showMixedAmount aebalance)
(showMixedAmount aibalance)
@ -159,7 +159,7 @@ showAccountDebug a = printf "%-25s %4s %4s %s"
(aname a)
(showMixedAmount $ aebalance a)
(showMixedAmount $ aibalance a)
(if aboring a then "b" else " ")
(if aboring a then "b" else " " :: String)
tests_Hledger_Data_Account = TestList [

View File

@ -146,16 +146,18 @@ divideAmount a@Amount{quantity=q} d = a{quantity=q/d}
isNegativeAmount :: Amount -> Bool
isNegativeAmount Amount{quantity=q} = q < 0
digits = "123456789" :: String
-- | Does this amount appear to be zero when displayed with its given precision ?
isZeroAmount :: Amount -> Bool
isZeroAmount a -- a==missingamt = False
| otherwise = (null . filter (`elem` "123456789") . showAmountWithoutPriceOrCommodity) a
| otherwise = (null . filter (`elem` digits) . showAmountWithoutPriceOrCommodity) a
-- | Is this amount "really" zero, regardless of the display precision ?
-- Since we are using floating point, for now just test to some high precision.
isReallyZeroAmount :: Amount -> Bool
isReallyZeroAmount a -- a==missingamt = False
| otherwise = (null . filter (`elem` "123456789") . printf ("%."++show zeroprecision++"f") . quantity) a
| otherwise = (null . filter (`elem` digits) . printf ("%."++show zeroprecision++"f") . quantity) a
where zeroprecision = 8
-- | Get the string representation of an amount, based on its commodity's
@ -200,10 +202,10 @@ showAmount a@(Amount (Commodity {symbol=sym,side=side,spaced=spaced}) _ pri) =
R -> printf "%s%s%s%s" quantity' space sym' price
where
quantity = showamountquantity a
displayingzero = null $ filter (`elem` "123456789") $ quantity
displayingzero = null $ filter (`elem` digits) $ quantity
(quantity',sym') | displayingzero = ("0","")
| otherwise = (quantity,quoteCommoditySymbolIfNeeded sym)
space = if (not (null sym') && spaced) then " " else ""
space = if (not (null sym') && spaced) then " " else "" :: String
price = maybe "" showPrice pri
-- | Get the string representation of the number part of of an amount,

View File

@ -18,7 +18,7 @@ import Hledger.Data.Types
import Hledger.Utils
nonsimplecommoditychars = "0123456789-.@;\n \""
nonsimplecommoditychars = "0123456789-.@;\n \"" :: String
quoteCommoditySymbolIfNeeded s | any (`elem` nonsimplecommoditychars) s = "\"" ++ s ++ "\""
| otherwise = s

View File

@ -1,3 +1,4 @@
{-# LANGUAGE NoMonoLocalBinds #-}
{-|
Date parsing and utilities for hledger.

View File

@ -340,7 +340,7 @@ nonzerobalanceerror t = printf "could not balance this transaction (%s%s%s)" rms
| otherwise = "real postings are off by " ++ showMixedAmount (costOfMixedAmount rsum)
bvmsg | isReallyZeroMixedAmountCost bvsum = ""
| otherwise = "balanced virtual postings are off by " ++ showMixedAmount (costOfMixedAmount bvsum)
sep = if not (null rmsg) && not (null bvmsg) then "; " else ""
sep = if not (null rmsg) && not (null bvmsg) then "; " else "" :: String
transactionActualDate :: Transaction -> Day
transactionActualDate = tdate

View File

@ -1,4 +1,4 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE RecordWildCards, NoMonoLocalBinds #-}
{-|
A reader for hledger's journal file format

View File

@ -55,7 +55,7 @@ lowercase = map toLower
uppercase = map toUpper
strip = lstrip . rstrip
lstrip = dropWhile (`elem` " \t")
lstrip = dropWhile (`elem` " \t") :: String -> String
rstrip = reverse . lstrip . reverse
elideLeft width s =

View File

@ -117,7 +117,7 @@ getPostings st enteredps = do
| otherwise = Nothing
where Just ps = historicalps
defaultaccount = maybe Nothing (Just . showacctname) bestmatch
ordot | null enteredps || length enteredrealps == 1 = ""
ordot | null enteredps || length enteredrealps == 1 = "" :: String
| otherwise = ", or . to record"
account <- runInteraction j $ askFor (printf "account %d%s" n ordot) defaultaccount (Just accept)
if account=="."

View File

@ -41,7 +41,7 @@ showLedgerStats l today span =
w1 = maximum $ map (length . fst) stats
-- w2 = maximum $ map (length . show . snd) stats
stats = [
("Main journal file", path) -- ++ " (from " ++ source ++ ")")
("Main journal file" :: String, path) -- ++ " (from " ++ source ++ ")")
,("Included journal files", unlines $ reverse $ -- cf journalAddFile
drop 1 $ journalFilePaths j)
,("Transactions span", printf "%s to %s (%d days)" (start span) (end span) days)
@ -69,7 +69,7 @@ showLedgerStats l today span =
showelapsed Nothing = ""
showelapsed (Just days) = printf " (%d %s)" days' direction
where days' = abs days
direction | days >= 0 = "days ago"
direction | days >= 0 = "days ago" :: String
| otherwise = "days from now"
tnum = length ts
start (DateSpan (Just d) _) = show d

View File

@ -55,7 +55,7 @@ binaryfilename progname = prettify $ splitAtElement '.' buildversion
| patches/="0" = '+' : patches
| otherwise = ""
(os',suffix)
| os == "darwin" = ("mac","")
| os == "darwin" = ("mac","" :: String)
| os == "mingw32" = ("windows",".exe")
| otherwise = (os,"")
prettify (major:minor:bugfix:[]) = prettify [major,minor,bugfix,"0"]