diff options
-rw-r--r-- | Cost.hs | 11 | ||||
-rw-r--r-- | Types/Cost.hs | 8 |
2 files changed, 8 insertions, 11 deletions
@@ -17,10 +17,15 @@ totalCost :: Cost op -> (Seconds, [UsingHardware]) totalCost (CPUCost s) = (s, [UsingCPU]) raiseCostPower :: Cost c -> Entropy e -> Cost c -raiseCostPower c (Entropy e) = adjustCost c (* 2^e) +raiseCostPower c (Entropy e) = mapCost (* 2^e) c -adjustCost :: Cost c -> (Seconds -> Seconds) -> Cost c -adjustCost (CPUCost s) f = CPUCost (f s) +mapCost :: (Integer -> Integer) -> Cost op -> Cost op +mapCost f (CPUCost (Seconds n)) = CPUCost (Seconds (f n)) + +showCostMinutes :: Cost op -> String +showCostMinutes (CPUCost (Seconds n)) + | n < 61 = "1 minute" + | otherwise = show (n `div` 60) ++ " minutes" castCost :: Cost a -> Cost b castCost (CPUCost s) = CPUCost s diff --git a/Types/Cost.hs b/Types/Cost.hs index b3aed71..e2a037d 100644 --- a/Types/Cost.hs +++ b/Types/Cost.hs @@ -26,14 +26,6 @@ instance Monoid (Cost t) where CPUCost (Seconds a) `mappend` CPUCost (Seconds b) = CPUCost (Seconds (a+b)) -mapCost :: (Integer -> Integer) -> Cost op -> Cost op -mapCost f (CPUCost (Seconds n)) = CPUCost (Seconds (f n)) - -showCostMinutes :: Cost op -> String -showCostMinutes (CPUCost (Seconds n)) - | n < 61 = "1 minute" - | otherwise = show (n `div` 60) ++ " minutes" - -- | Operations whose cost can be measured. data DecryptionOp data CreationOp |