@@ -131,7 +131,8 @@ instance Semigroup API where
131131 (<>) = mappend
132132
133133instance Monoid API where
134− API a1 b1 `mappend` API a2 b2 = API (a1 `mappend` a2) (b1 `mappend` b2)
134+ API a1 b1 `mappend` API a2 b2 = API (a1 `mappend` a2)
135+ (HM.unionWith combineAction b1 b2)
135136 mempty = API mempty mempty
136137
137138-- | An empty 'API'
@@ -240,6 +241,15 @@ data Response = Response
240241 , _respHeaders :: [HTTP.Header]
241242 } deriving (Eq, Ord, Show)
242243
244+-- | Combine two Responses, we can't make a monoid because merging Status breaks
245+-- the laws.
246+--
247+-- As such, we invent a non-commutative, left associative operation
248+-- 'combineResponse' to mush two together taking the status from the very left.
249+combineResponse :: Response -> Response -> Response
250+Response s ts bs hs `combineResponse` Response _ ts' bs' hs'
251+ = Response s (ts <> ts') (bs <> bs') (hs <> hs')
252+
243253-- | Default response: status code 200, no response body.
244254--
245255-- Can be tweaked with four lenses.
@@ -284,11 +294,10 @@ data Action = Action
284294-- laws.
285295--
286296-- As such, we invent a non-commutative, left associative operation
287−-- 'combineAction' to mush two together taking the response, body and content
288−-- types from the very left.
297+-- 'combineAction' to mush two together taking the response from the very left.
289298combineAction :: Action -> Action -> Action
290−Action a c h p n m ts body resp `combineAction` Action a' c' h' p' n' m' _ _ _ =
291− Action (a <> a') (c <> c') (h <> h') (p <> p') (n <> n') (m <> m') ts body resp
299+Action a c h p n m ts body resp `combineAction` Action a' c' h' p' n' m' ts' body' resp' =
300+ Action (a <> a') (c <> c') (h <> h') (p <> p') (n <> n') (m <> m') (ts <> ts') (body <> body') (resp `combineResponse` resp')
292301
293302-- | Default 'Action'. Has no 'captures', no query 'params', expects
294303-- no request body ('rqbody') and the typical response is 'defResponse'.