diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-02-17 08:37:05 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-02-17 08:37:05 -0700 |
commit | 0fc5c49d067747c97f6e774001df67b27a304983 (patch) | |
tree | 6e59b61894adf77a2fbaf8a257690a672dec6a90 /Types/Cost.hs | |
parent | f9f821b71530dbcab61b96b589e6e87e8952e198 (diff) | |
parent | de59756b62fdb8045217e3474f2528bcb48508ed (diff) | |
download | keysafe-0fc5c49d067747c97f6e774001df67b27a304983.tar.gz |
Merge tag '0.20200214'
tagging package keysafe version 0.20200214
# gpg: Signature made Fri 14 Feb 2020 10:39:08 AM MST
# gpg: using RSA key 28A500C35207EAB72F6C0F25DB12DB0FF05F8F38
# gpg: Good signature from "Joey Hess <joeyh@joeyh.name>" [full]
# Primary key fingerprint: E85A 5F63 B31D 24C1 EBF0 D81C C910 D922 2512 E3C7
# Subkey fingerprint: 28A5 00C3 5207 EAB7 2F6C 0F25 DB12 DB0F F05F 8F38
Diffstat (limited to 'Types/Cost.hs')
-rw-r--r-- | Types/Cost.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Types/Cost.hs b/Types/Cost.hs index 521d6c1..cd0a9f6 100644 --- a/Types/Cost.hs +++ b/Types/Cost.hs @@ -26,13 +26,15 @@ newtype Divisibility = Divisibility Integer data UsingHardware = UsingCPU | UsingGPU | UsingASIC deriving (Show) -instance Monoid (Cost t) where - mempty = CPUCost (Seconds 0) (Divisibility 1) - CPUCost (Seconds a) (Divisibility x) `mappend` CPUCost (Seconds b) (Divisibility y) = +instance Semigroup (Cost t) where + CPUCost (Seconds a) (Divisibility x) <> CPUCost (Seconds b) (Divisibility y) = -- Take maximum divisibility, to avoid over-estimating -- the total cost. CPUCost (Seconds (a+b)) (Divisibility $ max x y) +instance Monoid (Cost t) where + mempty = CPUCost (Seconds 0) (Divisibility 1) + -- | Operations whose cost can be measured. data DecryptionOp data CreationOp |