diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-16 23:53:30 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-16 23:53:30 -0400 |
commit | fc50d28c84fe7c79d47e89e93e959dbaa68cda5b (patch) | |
tree | aca07262bf025fd4ab54188841e7f75d05872624 | |
parent | c2eba63d11c748aeebdd3a4a3a5b015ac5e2f2c9 (diff) | |
download | keysafe-fc50d28c84fe7c79d47e89e93e959dbaa68cda5b.tar.gz |
improve cost table
-rw-r--r-- | Cost.hs | 10 | ||||
-rw-r--r-- | keysafe.hs | 3 |
2 files changed, 11 insertions, 2 deletions
@@ -102,3 +102,13 @@ costOverTime (Dollars currcost) thisyear = let monthdelta = (fromIntegral ((y * 12) - (thisyear * 12))) :: Double cost = floor $ fromIntegral currcost / 2 ** (monthdelta / 18) in (Dollars cost, y) + +costOverTimeTable :: Dollars -> Year -> [String] +costOverTimeTable cost thisyear = go [] thisyear $ costOverTime cost thisyear + where + go t _ [] = reverse t + go t yprev ((c, y):ys) = + let s = " " ++ show y ++ ":\t" ++ show c + in if yprev < y - 1 + then go (s:" ...":t) y ys + else go (s:t) y ys @@ -134,8 +134,7 @@ backup ui tunables secretkeysource secretkey = do ] crackdesc crackcost thisyear = unlines $ "Rough estimate of the cost to crack your password: " : - map (\(c, y) -> " " ++ show y ++ ":\t" ++ show c) - (costOverTime crackcost thisyear) + costOverTimeTable crackcost thisyear restore :: UI -> SecretKeySource -> IO () restore ui secretkeydest = do |