hedis 0.10.0 → 0.10.1
raw patch · 3 files changed
+36/−20 lines, 3 filesdep +semigroupsdep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: semigroups
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG +4/−0
- hedis.cabal +7/−4
- src/Database/Redis/PubSub.hs +25/−16
CHANGELOG view
@@ -1,5 +1,9 @@ # Changelog for Hedis +## 0.10.1++* PR #104. Add a Semigroup instance (fix GHC 8.4)+ ## 0.10.0 * PR #102. Return list from srandmemberN
hedis.cabal view
@@ -1,5 +1,5 @@ name: hedis-version: 0.10.0+version: 0.10.1 synopsis: Client library for the Redis datastore: supports full command set, pipelining.@@ -12,9 +12,9 @@ . [Compatibility with Latest Stable Redis:] Hedis is intended to be used with the latest stable version of Redis (currently 3.2).- Most redis commands (<http://redis.io/commands>) are available as- haskell functions, although MONITOR and SYNC are intentionally- omitted. Additionally, a low-level API is+ Most redis commands (<http://redis.io/commands>) are available as+ haskell functions, although MONITOR and SYNC are intentionally+ omitted. Additionally, a low-level API is exposed that makes it easy for the library user to implement further commands, such as new commands from an experimental Redis version. .@@ -82,6 +82,9 @@ HTTP, errors, network-uri+ if !impl(ghc >= 8.0)+ build-depends:+ semigroups >= 0.11 && < 0.19 other-modules: Database.Redis.Core, Database.Redis.ProtocolPipelining,
src/Database/Redis/PubSub.hs view
@@ -22,7 +22,7 @@ #if __GLASGOW_HASKELL__ < 710 import Control.Applicative-import Data.Monoid+import Data.Monoid hiding (<>) #endif import Control.Concurrent.Async (withAsync, waitEitherCatch, waitEitherCatchSTM) import Control.Concurrent.STM@@ -33,6 +33,7 @@ import Data.List (foldl') import Data.Maybe (isJust) import Data.Pool+import Data.Semigroup (Semigroup(..)) import qualified Data.HashMap.Strict as HM import qualified Database.Redis.Core as Core import qualified Database.Redis.ProtocolPipelining as PP@@ -66,31 +67,39 @@ , punsubs :: Cmd Unsubscribe Pattern } deriving (Eq) -instance Monoid PubSub where- mempty = PubSub mempty mempty mempty mempty- mappend p1 p2 = PubSub { subs = subs p1 `mappend` subs p2+instance Semigroup PubSub where+ (<>) p1 p2 = PubSub { subs = subs p1 `mappend` subs p2 , unsubs = unsubs p1 `mappend` unsubs p2 , psubs = psubs p1 `mappend` psubs p2 , punsubs = punsubs p1 `mappend` punsubs p2 } +instance Monoid PubSub where+ mempty = PubSub mempty mempty mempty mempty+ mappend = (<>)+ data Cmd a b = DoNothing | Cmd { changes :: [ByteString] } deriving (Eq) +instance Semigroup (Cmd Subscribe a) where+ (<>) DoNothing x = x+ (<>) x DoNothing = x+ (<>) (Cmd xs) (Cmd ys) = Cmd (xs ++ ys)+ instance Monoid (Cmd Subscribe a) where- mempty = DoNothing- mappend DoNothing x = x- mappend x DoNothing = x- mappend (Cmd xs) (Cmd ys) = Cmd (xs ++ ys)+ mempty = DoNothing+ mappend = (<>) -instance Monoid (Cmd Unsubscribe a) where- mempty = DoNothing- mappend DoNothing x = x- mappend x DoNothing = x- -- empty subscription list => unsubscribe all channels and patterns- mappend (Cmd []) _ = Cmd []- mappend _ (Cmd []) = Cmd []- mappend (Cmd xs) (Cmd ys) = Cmd (xs ++ ys)+instance Semigroup (Cmd Unsubscribe a) where+ (<>) DoNothing x = x+ (<>) x DoNothing = x+ -- empty subscription list => unsubscribe all channels and patterns+ (<>) (Cmd []) _ = Cmd []+ (<>) _ (Cmd []) = Cmd []+ (<>) (Cmd xs) (Cmd ys) = Cmd (xs ++ ys) +instance Monoid (Cmd Unsubscribe a) where+ mempty = DoNothing+ mappend = (<>) class Command a where redisCmd :: a -> ByteString