@@ -44,46 +44,46 @@ newtype JSXMLHttpRequest = JSXMLHttpRequest JSVal
45newtype JSXMLHttpRequestClass = JSXMLHttpRequestClass JSVal
45newtype JSXMLHttpRequestClass = JSXMLHttpRequestClass JSVal
47−newtype GhcjsClientEnv
47+newtype ClientEnv
48− = GhcjsClientEnv
48+ = ClientEnv
49 { baseUrl :: BaseUrl }
49 { baseUrl :: BaseUrl }
50 deriving (Eq, Show)
50 deriving (Eq, Show)
52−client :: HasClient GhcjsClientM api => Proxy api -> Client GhcjsClientM api
52+client :: HasClient ClientM api => Proxy api -> Client ClientM api
53−client api = api `clientIn` (Proxy :: Proxy GhcjsClientM)
53+client api = api `clientIn` (Proxy :: Proxy ClientM)
55−newtype GhcjsClientM a = GhcjsClientM
55+newtype ClientM a = ClientM
56− { runGhcjsClientM' :: ReaderT GhcjsClientEnv (ExceptT ServantError IO) a }
56+ { runClientM' :: ReaderT ClientEnv (ExceptT ServantError IO) a }
57 deriving ( Functor, Applicative, Monad, MonadIO, Generic
57 deriving ( Functor, Applicative, Monad, MonadIO, Generic
58− , MonadReader GhcjsClientEnv, MonadError ServantError, MonadThrow
58+ , MonadReader ClientEnv, MonadError ServantError, MonadThrow
59 , MonadCatch)
59 , MonadCatch)
61−instance MonadBase IO GhcjsClientM where
61+instance MonadBase IO ClientM where
62− liftBase = GhcjsClientM . liftBase
62+ liftBase = ClientM . liftBase
64−instance MonadBaseControl IO GhcjsClientM where
64+instance MonadBaseControl IO ClientM where
65− type StM GhcjsClientM a = Either ServantError a
65+ type StM ClientM a = Either ServantError a
67− liftBaseWith f = GhcjsClientM (liftBaseWith (\g -> f (g . runGhcjsClientM')))
67+ liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . runClientM')))
69− restoreM st = GhcjsClientM (restoreM st)
69+ restoreM st = ClientM (restoreM st)
71-- | Try clients in order, last error is preserved.
71-- | Try clients in order, last error is preserved.
72−instance Alt GhcjsClientM where
72+instance Alt ClientM where
73 a <!> b = a `catchError` const b
73 a <!> b = a `catchError` const b
75−instance RunClient GhcjsClientM where
75+instance RunClient ClientM where
76 runRequest = performRequest
76 runRequest = performRequest
77 throwServantError = throwError
77 throwServantError = throwError
78 catchServantError = catchError
78 catchServantError = catchError
80−instance ClientLike (GhcjsClientM a) (GhcjsClientM a) where
80+instance ClientLike (ClientM a) (ClientM a) where
81 mkClient = id
81 mkClient = id
83−runGhcjsClientM :: GhcjsClientM a -> GhcjsClientEnv -> IO (Either ServantError a)
83+runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a)
84−runGhcjsClientM cm env = runExceptT $ flip runReaderT env $ runGhcjsClientM' cm
84+runClientM cm env = runExceptT $ flip runReaderT env $ runClientM' cm
86−performRequest :: Request -> GhcjsClientM Response
86+performRequest :: Request -> ClientM Response
87performRequest req = do
87performRequest req = do
88 xhr <- liftIO initXhr
88 xhr <- liftIO initXhr
89 burl <- asks baseUrl
89 burl <- asks baseUrl
@@ -188,7 +188,7 @@ toBody request = case requestBody request of
189-- This function is only supposed to handle 'ConnectionError's. Other
189-- This function is only supposed to handle 'ConnectionError's. Other
190-- 'ServantError's are created in Servant.Client.Req.
190-- 'ServantError's are created in Servant.Client.Req.
191−toResponse :: JSXMLHttpRequest -> GhcjsClientM Response
191+toResponse :: JSXMLHttpRequest -> ClientM Response
192toResponse xhr = do
192toResponse xhr = do
193 status <- liftIO $ getStatus xhr
193 status <- liftIO $ getStatus xhr
194 case status of
194 case status of