git.iko.soy/typeable/pagerduty
on develop help sign in
Removing orphan instance
commit4da03b5c628ada2775391d5e15fc7a28baf1222f authorBrendan Hay <brendan.g.hay@gmail.com> dateWed 10 Feb 2016, 11:23 (11 years ago) parent14d1e06
2 files changed+11−7
src/Network/PagerDuty/Internal/Types.hs+7−2 src/Network/PagerDuty/REST.hs+4−5
src/Network/PagerDuty/Internal/Types.hs+7−2
@@ -279,8 +279,13 @@ data Pager = Pager
279279
280280makeLenses ''Pager
281281
282−instance FromJSON a => FromJSON (a, Maybe Pager) where
283− parseJSON = withObject "paginated" $ \o -> (,)
282+data Page a = Page
283+ { _pgItem :: a
284+ , _pgPager :: Maybe Pager
285+ }
286+
287+instance FromJSON a => FromJSON (Page a) where
288+ parseJSON = withObject "paginated" $ \o -> Page
284289 <$> parseJSON (Object o)
285290 <*> optional (parse o)
286291 where
src/Network/PagerDuty/REST.hs+4−5
@@ -13,7 +13,6 @@
1313
1414module Network.PagerDuty.REST
1515 (
16−
1716 -- * Sending requests
1817 send
1918 , sendWith
@@ -56,7 +55,7 @@ sendWith :: (MonadIO m, FromJSON b)
5655 => Env s
5756 -> Request a s b
5857 -> m (Either Error b)
59−sendWith e = liftM (fmap fst) . http e
58+sendWith e = liftM (fmap _pgItem) . http e
6059
6160-- | /See:/ 'paginateWith'
6261paginate :: (MonadIO m, Paginate a, FromJSON b)
@@ -75,15 +74,15 @@ paginateWith e = go
7574 where
7675 go rq = do
7776 rs <- lift (http e rq)
78− yield (fst <$> rs)
77+ yield (_pgItem <$> rs)
7978 either (const (return ()))
80− (maybe (return ()) go . next rq . snd)
79+ (maybe (return ()) go . next rq . _pgPager)
8180 rs
8281
8382http :: (MonadIO m, FromJSON b)
8483 => Env s
8584 -> Request a s b
86− -> m (Either Error (b, Maybe Pager))
85+ -> m (Either Error (Page b))
8786http e rq = request (e ^. envManager) (e ^. envLogger) rq $ raw
8887 { Client.host = domain (e ^. envDomain)
8988 , Client.path = renderPath (rq ^. path)