summaryrefslogtreecommitdiffhomepage
path: root/Cost.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-01-14 19:32:37 +1100
committerJoey Hess <joeyh@joeyh.name>2017-01-14 19:32:37 +1100
commitb76c1bd252721547e6365f96d87fe496eab673e1 (patch)
treecbf7c65395fd95c5d5bdfee20058822d5f95e110 /Cost.hs
parentd5f31fa7f48c9b3827ccd7f7b7224461cb9e1094 (diff)
downloadkeysafe-b76c1bd252721547e6365f96d87fe496eab673e1.tar.gz
Clarify that dollars in cost estimates are USD.
This commit was sponsored by Ignacio on Patreon.
Diffstat (limited to 'Cost.hs')
-rw-r--r--Cost.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Cost.hs b/Cost.hs
index dc2438e..a18a088 100644
--- a/Cost.hs
+++ b/Cost.hs
@@ -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)