@@ -12,6 +12,7 @@
1212{-# LANGUAGE MultiParamTypeClasses #-}
1313{-# LANGUAGE OverloadedStrings #-}
1414{-# LANGUAGE PolyKinds #-}
15+{-# LANGUAGE Rank2Types #-}
1516{-# LANGUAGE RecordWildCards #-}
1617{-# LANGUAGE ScopedTypeVariables #-}
1718{-# LANGUAGE TupleSections #-}
@@ -30,7 +31,9 @@
3031module Servant.Reflex
3132 ( client
3233 , clientWithOpts
34+ , clientWithOptsAndResultHandler
3335 , clientWithRoute
36+ , clientWithRouteAndResultHandler
3437 , BuildHeaderKeysTo(..)
3538 , GHCJS'MimeRender(..)
3639 , toHeaders
@@ -173,21 +176,53 @@ clientWithOpts
173176 -> Client t m layout tag
174177clientWithOpts p q t baseurl = clientWithRoute p q t defReq baseurl
175178
179+-- | Like 'clientWithOpts' but allows passing a function which will process the
180+-- result event in some way. This can be used to handle errors in a uniform way
181+-- across call sites.
182+clientWithOptsAndResultHandler
183+ :: (HasClient t m layout tag)
184+ => Proxy layout
185+ -> Proxy m
186+ -> Proxy tag
187+ -> Dynamic t BaseUrl
188+ -> ClientOptions
189+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
190+ -> Client t m layout tag
191+clientWithOptsAndResultHandler p q t = clientWithRouteAndResultHandler p q t defReq
192+
176193
177194-- | This class lets us define how each API combinator
178195-- influences the creation of an HTTP request. It's mostly
179196-- an internal class, you can just use 'client'.
180−class HasClient t m layout (tag :: Type) where
181− type Client t m layout tag :: Type
182− clientWithRoute :: Proxy layout -> Proxy m -> Proxy tag -> Req t -> Dynamic t BaseUrl -> ClientOptions -> Client t m layout tag
197+class Monad m => HasClient t m layout (tag :: *) where
198+ type Client t m layout tag :: *
199+ clientWithRoute
200+ :: Proxy layout
201+ -> Proxy m
202+ -> Proxy tag
203+ -> Req t
204+ -> Dynamic t BaseUrl
205+ -> ClientOptions
206+ -> Client t m layout tag
207+ clientWithRoute l m t r b o = clientWithRouteAndResultHandler l m t r b o return
208+
209+ clientWithRouteAndResultHandler
210+ :: Proxy layout
211+ -> Proxy m
212+ -> Proxy tag
213+ -> Req t
214+ -> Dynamic t BaseUrl
215+ -> ClientOptions
216+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
217+ -> Client t m layout tag
183218
184219
185220instance (HasClient t m a tag, HasClient t m b tag) => HasClient t m (a :<|> b) tag where
186221 type Client t m (a :<|> b) tag = Client t m a tag :<|> Client t m b tag
187222
188− clientWithRoute Proxy q pTag req baseurl opts =
189− clientWithRoute (Proxy :: Proxy a) q pTag req baseurl opts :<|>
190− clientWithRoute (Proxy :: Proxy b) q pTag req baseurl opts
223+ clientWithRouteAndResultHandler Proxy q pTag req baseurl opts wrap =
224+ clientWithRouteAndResultHandler (Proxy :: Proxy a) q pTag req baseurl opts wrap :<|>
225+ clientWithRouteAndResultHandler (Proxy :: Proxy b) q pTag req baseurl opts wrap
191226
192227
193228-- Capture. Example:
@@ -208,11 +243,9 @@ instance (SupportsServantReflex t m, ToHttpApiData a, HasClient t m sublayout ta
208243 type Client t m (Capture capture a :> sublayout) tag =
209244 Dynamic t (Either Text a) -> Client t m sublayout tag
210245
211− clientWithRoute Proxy q t req baseurl opts val =
212− clientWithRoute (Proxy :: Proxy sublayout)
213− q t
214− (prependToPathParts p req)
215− baseurl opts
246+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap val =
247+ clientWithRouteAndResultHandler
248+ (Proxy :: Proxy sublayout) q t (prependToPathParts p req) baseurl opts wrap
216249 where p = (fmap . fmap) (toUrlPiece) val
217250
218251
@@ -225,8 +258,8 @@ instance {-# OVERLAPPABLE #-}
225258 Event t tag -> m (Event t (ReqResult tag a))
226259 -- TODO how to access input types here?
227260 -- ExceptT ServantError IO a
228− clientWithRoute Proxy _ _ req baseurl opts trigs =
229− fmap runIdentity <$> performRequestsCT (Proxy :: Proxy ct) method (constDyn $ Identity $ req') baseurl opts trigs
261+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs =
262+ wrap =<< fmap runIdentity <$> performRequestsCT (Proxy :: Proxy ct) method (constDyn $ Identity $ req') baseurl opts trigs
230263 where method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
231264 req' = req { reqMethod = method }
232265
@@ -239,8 +272,8 @@ instance {-# OVERLAPPING #-}
239272 Event t tag -> m (Event t (ReqResult tag NoContent))
240273 -- TODO: how to access input types here?
241274 -- ExceptT ServantError IO NoContent
242− clientWithRoute Proxy _ _ req baseurl opts =
243− (fmap . fmap) runIdentity . performRequestsNoBody method (constDyn $ Identity req) baseurl opts
275+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs =
276+ wrap =<< fmap runIdentity <$> performRequestsNoBody method (constDyn $ Identity req) baseurl opts trigs
244277 where method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
245278
246279
@@ -276,10 +309,10 @@ instance {-# OVERLAPPABLE #-}
276309 ) => HasClient t m (Verb method status cts' (Headers ls a)) tag where
277310 type Client t m (Verb method status cts' (Headers ls a)) tag =
278311 Event t tag -> m (Event t (ReqResult tag (Headers ls a)))
279− clientWithRoute Proxy _ _ req baseurl opts trigs = do
312+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs = do
280313 let method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
281314 resp <- fmap runIdentity <$> performRequestsCT (Proxy :: Proxy ct) method (constDyn $ Identity req') baseurl opts trigs
282− return $ toHeaders <$> resp
315+ wrap $ toHeaders <$> resp
283316 where req' = req { respHeaders =
284317 OnlyHeaders (Set.fromList (buildHeaderKeysTo (Proxy :: Proxy ls)))
285318 }
@@ -292,10 +325,10 @@ instance {-# OVERLAPPABLE #-}
292325 ) => HasClient t m (Verb method status cts (Headers ls NoContent)) tag where
293326 type Client t m (Verb method status cts (Headers ls NoContent)) tag
294327 = Event t tag -> m (Event t (ReqResult tag (Headers ls NoContent)))
295− clientWithRoute Proxy _ _ req baseurl opts trigs = do
328+ clientWithRouteAndResultHandler Proxy _ _ req baseurl opts wrap trigs = do
296329 let method = E.decodeUtf8 $ reflectMethod (Proxy :: Proxy method)
297330 resp <- fmap runIdentity <$> performRequestsNoBody method (constDyn $ Identity req') baseurl opts trigs
298− return $ toHeaders <$> resp
331+ wrap $ toHeaders <$> resp
299332 where req' = req {respHeaders =
300333 OnlyHeaders (Set.fromList (buildHeaderKeysTo (Proxy :: Proxy ls)))
301334 }
@@ -322,11 +355,11 @@ instance (KnownSymbol sym, ToHttpApiData a,
322355 type Client t m (Header sym a :> sublayout) tag =
323356 Dynamic t (Either Text a) -> Client t m sublayout tag
324357
325− clientWithRoute Proxy q t req baseurl opts eVal =
326− clientWithRoute (Proxy :: Proxy sublayout)
327− q t
328− (Servant.Common.Req.addHeader hname eVal req)
329− baseurl opts
358+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap eVal =
359+ clientWithRouteAndResultHandler
360+ (Proxy :: Proxy sublayout) q t
361+ (Servant.Common.Req.addHeader hname eVal req)
362+ baseurl opts wrap
330363 where hname = T.pack $ symbolVal (Proxy :: Proxy sym)
331364
332365
@@ -340,8 +373,8 @@ instance HasClient t m sublayout tag
340373 type Client t m (HttpVersion :> sublayout) tag =
341374 Client t m sublayout tag
342375
343− clientWithRoute Proxy q t =
344− clientWithRoute (Proxy :: Proxy sublayout) q t
376+ clientWithRouteAndResultHandler Proxy =
377+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout)
345378
346379
347380-- | If you use a 'QueryParam' in one of your endpoints in your API,
@@ -377,9 +410,9 @@ instance (KnownSymbol sym, ToHttpApiData a, HasClient t m sublayout tag, Reflex
377410 Dynamic t (QParam a) -> Client t m sublayout tag
378411
379412 -- if mparam = Nothing, we don't add it to the query string
380− clientWithRoute Proxy q t req baseurl opts mparam =
381− clientWithRoute (Proxy :: Proxy sublayout) q t
382− (req {qParams = paramPair : qParams req}) baseurl opts
413+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap mparam =
414+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t
415+ (req {qParams = paramPair : qParams req}) baseurl opts wrap
383416
384417 where pname = symbolVal (Proxy :: Proxy sym)
385418 --p prm = QueryPartParam $ (fmap . fmap) (toQueryParam) prm
@@ -423,8 +456,8 @@ instance (KnownSymbol sym, ToHttpApiData a, HasClient t m sublayout tag, Reflex
423456 type Client t m (QueryParams sym a :> sublayout) tag =
424457 Dynamic t [a] -> Client t m sublayout tag
425458
426− clientWithRoute Proxy q t req baseurl opts paramlist =
427− clientWithRoute (Proxy :: Proxy sublayout) q t req' baseurl opts
459+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap paramlist =
460+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t req' baseurl opts wrap
428461
429462 where req' = req { qParams = (T.pack pname, params') : qParams req }
430463 pname = symbolVal (Proxy :: Proxy sym)
@@ -463,8 +496,8 @@ instance (KnownSymbol sym, HasClient t m sublayout tag, Reflex t)
463496 type Client t m (QueryFlag sym :> sublayout) tag =
464497 Dynamic t Bool -> Client t m sublayout tag
465498
466− clientWithRoute Proxy q t req baseurl opts flag =
467− clientWithRoute (Proxy :: Proxy sublayout) q t req' baseurl opts
499+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap flag =
500+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t req' baseurl opts wrap
468501
469502 where req' = req { qParams = thisPair : qParams req }
470503 thisPair = (T.pack pName, QueryPartFlag flag) :: (Text, QueryPart t)
@@ -478,7 +511,7 @@ instance SupportsServantReflex t m => HasClient t m Raw tag where
478511 -> Event t tag
479512 -> m (Event t (ReqResult tag ()))
480513
481− clientWithRoute _ _ _ _ baseurl _ xhrs triggers = do
514+ clientWithRouteAndResultHandler _ _ _ _ baseurl _ wrap xhrs triggers = do
482515
483516 let xhrs' = liftA2 (\x path -> case x of
484517 Left e -> Left e
@@ -489,7 +522,7 @@ instance SupportsServantReflex t m => HasClient t m Raw tag where
489522 okReq = fmapMaybe (\(t,x) -> either (const Nothing) (Just . (t,)) x) xhrs'' :: Event t (tag, XhrRequest ())
490523
491524 resps <- performRequestsAsync okReq
492− return $ leftmost [ uncurry RequestFailure <$> badReq
525+ wrap $ leftmost [ uncurry RequestFailure <$> badReq
493526 , evalResponse (const $ Right ()) <$> resps
494527 ]
495528
@@ -521,8 +554,8 @@ instance (GHCJS'MimeRender ct a, IsXhrPayload (ToSend ct a), Show (ToSend ct a),
521554 type Client t m (ReqBody (ct ': cts) a :> sublayout) tag =
522555 Dynamic t (Either Text (ToConvert ct a)) -> Client t m sublayout tag
523556
524− clientWithRoute Proxy q t Req{..} baseurl opts body =
525− clientWithRoute (Proxy :: Proxy sublayout) q t req' baseurl opts
557+ clientWithRouteAndResultHandler Proxy q t Req{..} baseurl opts wrap body =
558+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t req' baseurl opts wrap
526559 where req' = Req { reqBody = Just $ (fmap . fmap)
527560 (\b -> (ghcjsMimeRender ctProxy atProxy b, ctString)) body
528561 , ..}
@@ -578,9 +611,9 @@ instance GHCJS'MimeRender PlainText BS.ByteString where
578611instance (KnownSymbol path, HasClient t m sublayout tag, Reflex t) => HasClient t m (path :> sublayout) tag where
579612 type Client t m (path :> sublayout) tag = Client t m sublayout tag
580613
581− clientWithRoute Proxy q t req baseurl opts =
582− clientWithRoute (Proxy :: Proxy sublayout) q t
583− (prependToPathParts (pure (Right $ T.pack p)) req) baseurl opts
614+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap =
615+ clientWithRouteAndResultHandler (Proxy :: Proxy sublayout) q t
616+ (prependToPathParts (pure (Right $ T.pack p)) req) baseurl opts wrap
584617
585618 where p = symbolVal (Proxy :: Proxy path)
586619
@@ -588,23 +621,23 @@ instance (KnownSymbol path, HasClient t m sublayout tag, Reflex t) => HasClient
588621instance HasClient t m api tag => HasClient t m (Vault :> api) tag where
589622 type Client t m (Vault :> api) tag = Client t m api tag
590623
591− clientWithRoute Proxy q t req baseurl =
592− clientWithRoute (Proxy :: Proxy api) q t req baseurl
624+ clientWithRouteAndResultHandler Proxy =
625+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
593626
594627
595628instance HasClient t m api tag => HasClient t m (RemoteHost :> api) tag where
596629 type Client t m (RemoteHost :> api) tag = Client t m api tag
597630
598− clientWithRoute Proxy q t req baseurl =
599− clientWithRoute (Proxy :: Proxy api) q t req baseurl
631+ clientWithRouteAndResultHandler Proxy =
632+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
600633
601634
602635
603636instance HasClient t m api tag => HasClient t m (IsSecure :> api) tag where
604637 type Client t m (IsSecure :> api) tag = Client t m api tag
605638
606− clientWithRoute Proxy q t req baseurl =
607− clientWithRoute (Proxy :: Proxy api) q t req baseurl
639+ clientWithRouteAndResultHandler Proxy =
640+ clientWithRouteAndResultHandler (Proxy :: Proxy api)
608641
609642
610643instance (HasClient t m api tag, Reflex t)
@@ -613,8 +646,8 @@ instance (HasClient t m api tag, Reflex t)
613646 type Client t m (BasicAuth realm usr :> api) tag = Dynamic t (Maybe BasicAuthData)
614647 -> Client t m api tag
615648
616− clientWithRoute Proxy q t req baseurl opts authdata =
617− clientWithRoute (Proxy :: Proxy api) q t req' baseurl opts
649+ clientWithRouteAndResultHandler Proxy q t req baseurl opts wrap authdata =
650+ clientWithRouteAndResultHandler (Proxy :: Proxy api) q t req' baseurl opts wrap
618651 where
619652 req' = req { authData = Just authdata }
620653
@@ -657,7 +690,7 @@ for empty and one for non-empty lists).
657690instance (HasCookieAuth auths, HasClient t m api tag) => HasClient t m (Auth.Auth auths a :> api) tag where
658691
659692 type Client t m (Auth.Auth auths a :> api) tag = Client t m api tag
660− clientWithRoute Proxy = clientWithRoute (Proxy :: Proxy api)
693+ clientWithRouteAndResultHandler Proxy = clientWithRouteAndResultHandler (Proxy :: Proxy api)
661694
662695
663696type family HasCookieAuth xs :: Constraint where
@@ -672,18 +705,19 @@ class CookieAuthNotEnabled
672705-}
673706
674707-- | Change a 'Throws' into 'Throwing'.
675−instance (HasClient t m (Throwing '[e] :> api) tag) => HasClient t m (Throws e :> api) tag where
708+instance (Monad m, HasClient t m (Throwing '[e] :> api) tag) => HasClient t m (Throws e :> api) tag where
676709 type Client t m (Throws e :> api) tag = Client t m (Throwing '[e] :> api) tag
677710
678− clientWithRoute
711+ clientWithRouteAndResultHandler
679712 :: Proxy (Throws e :> api)
680713 -> Proxy m
681714 -> Proxy tag
682715 -> Req t
683716 -> Dynamic t BaseUrl
684717 -> ClientOptions
718+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
685719 -> Client t m (Throwing '[e] :> api) tag
686− clientWithRoute _ = clientWithRoute (Proxy :: Proxy (Throwing '[e] :> api))
720+ clientWithRouteAndResultHandler _ = clientWithRouteAndResultHandler (Proxy :: Proxy (Throwing '[e] :> api))
687721
688722-- | When @'Throwing' es@ comes before a 'Verb', change it into the same 'Verb'
689723-- but returning an @'Envelope' es@.
@@ -693,109 +727,116 @@ instance (HasClient t m (Verb method status ctypes (Envelope es a)) tag) =>
693727 type Client t m (Throwing es :> Verb method status ctypes a) tag =
694728 Client t m (Verb method status ctypes (Envelope es a)) tag
695729
696− clientWithRoute
730+ clientWithRouteAndResultHandler
697731 :: Proxy (Throwing es :> Verb method status ctypes a)
698732 -> Proxy m
699733 -> Proxy tag
700734 -> Req t
701735 -> Dynamic t BaseUrl
702736 -> ClientOptions
737+ -> (forall x. Event t (ReqResult tag x) -> m (Event t (ReqResult tag x)))
703738 -> Client t m (Verb method status ctypes (Envelope es a)) tag
704− clientWithRoute Proxy =
705− clientWithRoute (Proxy :: Proxy (Verb method status ctypes (Envelope es a)))
739+ clientWithRouteAndResultHandler Proxy =
740+ clientWithRouteAndResultHandler (Proxy :: Proxy (Verb method status ctypes (Envelope es a)))
706741
707742-- | When 'NoThrow' comes before a 'Verb', change it into the same 'Verb'
708743-- but returning an @'Envelope' \'[]@.
709−instance (HasClient t m (Verb method status ctypes (Envelope '[] a)) tag) =>
744+instance (Monad m, HasClient t m (Verb method status ctypes (Envelope '[] a)) tag) =>
710745 HasClient t m (NoThrow :> Verb method status ctypes a) tag where
711746
712747 type Client t m (NoThrow :> Verb method status ctypes a) tag =
713748 Client t m (Verb method status ctypes (Envelope '[] a)) tag
714749
715− clientWithRoute
750+ clientWithRouteAndResultHandler
716751 :: Proxy (NoThrow :> Verb method status ctypes a)
717752 -> Proxy m
718753 -> Proxy tag
719754 -> Req t
720755 -> Dynamic t BaseUrl
721756 -> ClientOptions
757+ -> (forall x. Event t (ReqResult tag x) -> m (Event t (ReqResult tag x)))
722758 -> Client t m (Verb method status ctypes (Envelope '[] a)) tag
723− clientWithRoute Proxy =
724− clientWithRoute (Proxy :: Proxy (Verb method status ctypes (Envelope '[] a)))
759+ clientWithRouteAndResultHandler Proxy =
760+ clientWithRouteAndResultHandler (Proxy :: Proxy (Verb method status ctypes (Envelope '[] a)))
725761
726762-- | When @'Throwing' es@ comes before ':<|>', push @'Throwing' es@ into each
727763-- branch of the API.
728−instance HasClient t m ((Throwing es :> api1) :<|> (Throwing es :> api2)) tag =>
764+instance (Monad m, HasClient t m ((Throwing es :> api1) :<|> (Throwing es :> api2)) tag) =>
729765 HasClient t m (Throwing es :> (api1 :<|> api2)) tag where
730766
731767 type Client t m (Throwing es :> (api1 :<|> api2)) tag =
732768 Client t m ((Throwing es :> api1) :<|> (Throwing es :> api2)) tag
733769
734− clientWithRoute
770+ clientWithRouteAndResultHandler
735771 :: Proxy (Throwing es :> (api1 :<|> api2))
736772 -> Proxy m
737773 -> Proxy tag
738774 -> Req t
739775 -> Dynamic t BaseUrl
740776 -> ClientOptions
777+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
741778 -> Client t m ((Throwing es :> api1) :<|> (Throwing es :> api2)) tag
742− clientWithRoute _ =
743− clientWithRoute (Proxy :: Proxy ((Throwing es :> api1) :<|> (Throwing es :> api2)))
779+ clientWithRouteAndResultHandler _ =
780+ clientWithRouteAndResultHandler (Proxy :: Proxy ((Throwing es :> api1) :<|> (Throwing es :> api2)))
744781
745782-- | When 'NoThrow' comes before ':<|>', push 'NoThrow' into each branch of the
746783-- API.
747−instance HasClient t m ((NoThrow :> api1) :<|> (NoThrow :> api2)) tag =>
784+instance (Monad m, HasClient t m ((NoThrow :> api1) :<|> (NoThrow :> api2)) tag) =>
748785 HasClient t m (NoThrow :> (api1 :<|> api2)) tag where
749786
750787 type Client t m (NoThrow :> (api1 :<|> api2)) tag =
751788 Client t m ((NoThrow :> api1) :<|> (NoThrow :> api2)) tag
752789
753− clientWithRoute
790+ clientWithRouteAndResultHandler
754791 :: Proxy (NoThrow :> (api1 :<|> api2))
755792 -> Proxy m
756793 -> Proxy tag
757794 -> Req t
758795 -> Dynamic t BaseUrl
759796 -> ClientOptions
797+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
760798 -> Client t m ((NoThrow :> api1) :<|> (NoThrow :> api2)) tag
761− clientWithRoute _ =
762− clientWithRoute (Proxy :: Proxy ((NoThrow :> api1) :<|> (NoThrow :> api2)))
799+ clientWithRouteAndResultHandler _ =
800+ clientWithRouteAndResultHandler (Proxy :: Proxy ((NoThrow :> api1) :<|> (NoThrow :> api2)))
763801
764802-- | When a @'Throws' e@ comes immediately after a @'Throwing' es@, 'Snoc' the
765803-- @e@ onto the @es@. Otherwise, if @'Throws' e@ comes before any other
766804-- combinator, push it down so it is closer to the 'Verb'.
767−instance HasClient t m (ThrowingNonterminal (Throwing es :> api :> apis)) tag =>
805+instance (Monad m, HasClient t m (ThrowingNonterminal (Throwing es :> api :> apis)) tag) =>
768806 HasClient t m (Throwing es :> api :> apis) tag where
769807
770808 type Client t m (Throwing es :> api :> apis) tag =
771809 Client t m (ThrowingNonterminal (Throwing es :> api :> apis)) tag
772810
773− clientWithRoute
811+ clientWithRouteAndResultHandler
774812 :: Proxy (Throwing es :> api :> apis)
775813 -> Proxy m
776814 -> Proxy tag
777815 -> Req t
778816 -> Dynamic t BaseUrl
779817 -> ClientOptions
818+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
780819 -> Client t m (ThrowingNonterminal (Throwing es :> api :> apis)) tag
781− clientWithRoute _ =
782− clientWithRoute (Proxy :: Proxy (ThrowingNonterminal (Throwing es :> api :> apis)))
820+ clientWithRouteAndResultHandler _ =
821+ clientWithRouteAndResultHandler (Proxy :: Proxy (ThrowingNonterminal (Throwing es :> api :> apis)))
783822
784823-- | When 'NoThrow' comes before any other combinator, push it down so it is
785824-- closer to the 'Verb'.
786−instance HasClient t m (api :> NoThrow :> apis) tag =>
825+instance (Monad m, HasClient t m (api :> NoThrow :> apis) tag) =>
787826 HasClient t m (NoThrow :> api :> apis) tag where
788827
789828 type Client t m (NoThrow :> api :> apis) tag =
790829 Client t m (api :> NoThrow :> apis) tag
791830
792− clientWithRoute
831+ clientWithRouteAndResultHandler
793832 :: Proxy (NoThrow :> api :> apis)
794833 -> Proxy m
795834 -> Proxy tag
796835 -> Req t
797836 -> Dynamic t BaseUrl
798837 -> ClientOptions
838+ -> (forall a. Event t (ReqResult tag a) -> m (Event t (ReqResult tag a)))
799839 -> Client t m (api :> NoThrow :> apis) tag
800− clientWithRoute _ =
801− clientWithRoute (Proxy :: Proxy (api :> NoThrow :> apis))
840+ clientWithRouteAndResultHandler _ =
841+ clientWithRouteAndResultHandler (Proxy :: Proxy (api :> NoThrow :> apis))
842+