diff options
Diffstat (limited to 'Cost.hs')
-rw-r--r-- | Cost.hs | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -92,6 +92,7 @@ estimateAttackCost dc opcost = centsToDollars $ costcents newtype Cents = Cents Integer deriving (Num, Integral, Enum, Real, Ord, Eq, Show) +-- | USD newtype Dollars = Dollars Integer deriving (Num, Integral, Enum, Real, Ord, Eq) @@ -103,12 +104,13 @@ instance Show Dollars where , (1000, "thousand") ] where - go [] = "$" ++ show n + go [] = fmt (show n) go ((d, u):us) | n >= d = let n' = n `div` d - in "$" ++ show n' ++ " " ++ u + in fmt (show n' ++ " " ++ u) | otherwise = go us + fmt d = "$" ++ d ++ " (USD)" centsToDollars :: Cents -> Dollars centsToDollars (Cents c) = Dollars (c `div` 100) |