@@ -11,7 +11,7 @@ import Data.CaseInsensitive (foldCase, foldedCase, mk)
11import Data.Either (isRight)
11import Data.Either (isRight)
12import Data.List.Split (wordsBy)
12import Data.List.Split (wordsBy)
13import Data.Maybe (fromMaybe, isJust)
13import Data.Maybe (fromMaybe, isJust)
14−import Data.Monoid ((<>))
14+import Data.Semigroup (Semigroup (..))
15import qualified Data.Text as T
15import qualified Data.Text as T
16import Data.Time (UTCTime, defaultTimeLocale, parseTimeM,
16import Data.Time (UTCTime, defaultTimeLocale, parseTimeM,
17 rfc822DateFormat)
17 rfc822DateFormat)
@@ -377,9 +377,12 @@ newtype ResponsePredicate = ResponsePredicate
377 { getResponsePredicate :: Response LBS.ByteString -> IO ()
377 { getResponsePredicate :: Response LBS.ByteString -> IO ()
378 } deriving (Generic)
378 } deriving (Generic)
380+instance Semigroup ResponsePredicate where
381+ ResponsePredicate a <> ResponsePredicate b = ResponsePredicate $ \x -> a x >> b x
380instance Monoid ResponsePredicate where
383instance Monoid ResponsePredicate where
381 mempty = ResponsePredicate $ const $ return ()
384 mempty = ResponsePredicate $ const $ return ()
382− ResponsePredicate a `mappend` ResponsePredicate b = ResponsePredicate $ \x -> a x >> b x
385+ mappend = (<>)
384-- | A predicate that depends on both the request and the response.
387-- | A predicate that depends on both the request and the response.
@@ -391,7 +394,11 @@ newtype RequestPredicate = RequestPredicate
391-- TODO: This isn't actually a monoid
394-- TODO: This isn't actually a monoid
392instance Monoid RequestPredicate where
395instance Monoid RequestPredicate where
393 mempty = RequestPredicate (\r m -> httpLbs r m >>= \x -> return ([x]))
396 mempty = RequestPredicate (\r m -> httpLbs r m >>= \x -> return ([x]))
399+-- TODO: This isn't actually a monoid
400+instance Semigroup RequestPredicate where
394− RequestPredicate a `mappend` RequestPredicate b = RequestPredicate $ \r mgr ->
401+ RequestPredicate a <> RequestPredicate b = RequestPredicate $ \r mgr ->
395 liftM2 (<>) (a r mgr) (b r mgr)
402 liftM2 (<>) (a r mgr) (b r mgr)
397-- | A set of predicates. Construct one with 'mempty' and '<%>'.
404-- | A set of predicates. Construct one with 'mempty' and '<%>'.
@@ -400,10 +407,13 @@ data Predicates = Predicates
400 , responsePredicates :: ResponsePredicate
407 , responsePredicates :: ResponsePredicate
401 } deriving (Generic)
408 } deriving (Generic)
410+instance Semigroup Predicates where
411+ a <> b = Predicates (requestPredicates a <> requestPredicates b)
412+ (responsePredicates a <> responsePredicates b)
403instance Monoid Predicates where
414instance Monoid Predicates where
404 mempty = Predicates mempty mempty
415 mempty = Predicates mempty mempty
405− a `mappend` b = Predicates (requestPredicates a <> requestPredicates b)
416+ mappend = (<>)
406− (responsePredicates a <> responsePredicates b)
408class JoinPreds a where
418class JoinPreds a where
409 joinPreds :: a -> Predicates -> Predicates
419 joinPreds :: a -> Predicates -> Predicates