diff options
author | joe <joe@jerkface.net> | 2018-06-22 07:20:24 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-06-22 07:22:33 -0400 |
commit | 40a8f0b6eb66bae93f8708dd84aaec57f7505c05 (patch) | |
tree | e328f56dd88433a00814452e60ead88acfe13f3b /src/Crypto | |
parent | 6bbc15735f6e28740c0e05fc8219fd83a5a464a4 (diff) |
Forward port to nightly-2018-06-22.
Diffstat (limited to 'src/Crypto')
-rw-r--r-- | src/Crypto/Tox.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs index d1992967..a1741a1f 100644 --- a/src/Crypto/Tox.hs +++ b/src/Crypto/Tox.hs | |||
@@ -83,6 +83,7 @@ import GHC.Exts (Constraint) | |||
83 | #endif | 83 | #endif |
84 | import Data.Ord | 84 | import Data.Ord |
85 | import Data.Serialize as S | 85 | import Data.Serialize as S |
86 | import Data.Semigroup | ||
86 | import Data.Word | 87 | import Data.Word |
87 | import Foreign.Marshal.Alloc | 88 | import Foreign.Marshal.Alloc |
88 | import Foreign.Ptr | 89 | import Foreign.Ptr |
@@ -159,11 +160,14 @@ instance Contravariant Size where | |||
159 | ConstSize n -> ConstSize n | 160 | ConstSize n -> ConstSize n |
160 | VarSize g -> VarSize (\x -> g (f x)) | 161 | VarSize g -> VarSize (\x -> g (f x)) |
161 | 162 | ||
163 | instance Semigroup (Size a) where | ||
164 | ConstSize x <> ConstSize y = ConstSize (x + y) | ||
165 | VarSize f <> ConstSize y = VarSize $ \x -> f x + y | ||
166 | ConstSize x <> VarSize g = VarSize $ \y -> x + g y | ||
167 | VarSize f <> VarSize g = VarSize $ \x -> f x + g x | ||
168 | |||
162 | instance Monoid (Size a) where | 169 | instance Monoid (Size a) where |
163 | ConstSize x `mappend` ConstSize y = ConstSize (x + y) | 170 | mappend = (<>) |
164 | VarSize f `mappend` ConstSize y = VarSize $ \x -> f x + y | ||
165 | ConstSize x `mappend` VarSize g = VarSize $ \y -> x + g y | ||
166 | VarSize f `mappend` VarSize g = VarSize $ \x -> f x + g x | ||
167 | mempty = ConstSize 0 | 171 | mempty = ConstSize 0 |
168 | 172 | ||
169 | 173 | ||