git.iko.soy/typeable/servant
on master help sign in
servant-client-ghcjs: Renamed GhcjsClientM to ClientM
commit8d1229f2d42895b83606cd243b59dd5a36f8ea7f authorFalco Peijnenburg <falco@lumiguide.nl> dateTue 26 Sep 2017, 21:38 (9 years ago) parent67f2285
2 files changed+23−23
servant-client-ghcjs/src/Servant/Client/Ghcjs.hs+3−3 servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs+20−20
servant-client-ghcjs/src/Servant/Client/Ghcjs.hs+3−3
@@ -4,9 +4,9 @@
44module Servant.Client.Ghcjs
55 (
66 client
7− , GhcjsClientM
8− , runGhcjsClientM
9− , GhcjsClientEnv(..)
7+ , ClientM
8+ , runClientM
9+ , ClientEnv(..)
1010 , module Servant.Client.Core.Reexport
1111 ) where
1212
servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs+20−20
@@ -44,46 +44,46 @@ newtype JSXMLHttpRequest = JSXMLHttpRequest JSVal
4444
4545newtype JSXMLHttpRequestClass = JSXMLHttpRequestClass JSVal
4646
47−newtype GhcjsClientEnv
48− = GhcjsClientEnv
47+newtype ClientEnv
48+ = ClientEnv
4949 { baseUrl :: BaseUrl }
5050 deriving (Eq, Show)
5151
52−client :: HasClient GhcjsClientM api => Proxy api -> Client GhcjsClientM api
53−client api = api `clientIn` (Proxy :: Proxy GhcjsClientM)
52+client :: HasClient ClientM api => Proxy api -> Client ClientM api
53+client api = api `clientIn` (Proxy :: Proxy ClientM)
5454
55−newtype GhcjsClientM a = GhcjsClientM
56− { runGhcjsClientM' :: ReaderT GhcjsClientEnv (ExceptT ServantError IO) a }
55+newtype ClientM a = ClientM
56+ { runClientM' :: ReaderT ClientEnv (ExceptT ServantError IO) a }
5757 deriving ( Functor, Applicative, Monad, MonadIO, Generic
58− , MonadReader GhcjsClientEnv, MonadError ServantError, MonadThrow
58+ , MonadReader ClientEnv, MonadError ServantError, MonadThrow
5959 , MonadCatch)
6060
61−instance MonadBase IO GhcjsClientM where
62− liftBase = GhcjsClientM . liftBase
61+instance MonadBase IO ClientM where
62+ liftBase = ClientM . liftBase
6363
64−instance MonadBaseControl IO GhcjsClientM where
65− type StM GhcjsClientM a = Either ServantError a
64+instance MonadBaseControl IO ClientM where
65+ type StM ClientM a = Either ServantError a
6666
67− liftBaseWith f = GhcjsClientM (liftBaseWith (\g -> f (g . runGhcjsClientM')))
67+ liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . runClientM')))
6868
69− restoreM st = GhcjsClientM (restoreM st)
69+ restoreM st = ClientM (restoreM st)
7070
7171-- | Try clients in order, last error is preserved.
72−instance Alt GhcjsClientM where
72+instance Alt ClientM where
7373 a <!> b = a `catchError` const b
7474
75−instance RunClient GhcjsClientM where
75+instance RunClient ClientM where
7676 runRequest = performRequest
7777 throwServantError = throwError
7878 catchServantError = catchError
7979
80−instance ClientLike (GhcjsClientM a) (GhcjsClientM a) where
80+instance ClientLike (ClientM a) (ClientM a) where
8181 mkClient = id
8282
83−runGhcjsClientM :: GhcjsClientM a -> GhcjsClientEnv -> IO (Either ServantError a)
84−runGhcjsClientM cm env = runExceptT $ flip runReaderT env $ runGhcjsClientM' cm
83+runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a)
84+runClientM cm env = runExceptT $ flip runReaderT env $ runClientM' cm
8585
86−performRequest :: Request -> GhcjsClientM Response
86+performRequest :: Request -> ClientM Response
8787performRequest req = do
8888 xhr <- liftIO initXhr
8989 burl <- asks baseUrl
@@ -188,7 +188,7 @@ toBody request = case requestBody request of
188188
189189-- This function is only supposed to handle 'ConnectionError's. Other
190190-- 'ServantError's are created in Servant.Client.Req.
191−toResponse :: JSXMLHttpRequest -> GhcjsClientM Response
191+toResponse :: JSXMLHttpRequest -> ClientM Response
192192toResponse xhr = do
193193 status <- liftIO $ getStatus xhr
194194 case status of