on master help sign in
servant-client-ghcjs: Renamed GhcjsClientM to ClientM
8d1229fFalco Peijnenburg
servant-client-ghcjs/src/Servant/Client/Ghcjs.hs+3−3
@@ -4,9 +4,9 @@
4module Servant.Client.Ghcjs
4module Servant.Client.Ghcjs
5 (
5 (
6 client
6 client
7− , GhcjsClientM
7+ , ClientM
8− , runGhcjsClientM
8+ , runClientM
9− , GhcjsClientEnv(..)
9+ , ClientEnv(..)
10 , module Servant.Client.Core.Reexport
10 , module Servant.Client.Core.Reexport
11 ) where
11 ) where
12
12
servant-client-ghcjs/src/Servant/Client/Internal/XhrClient.hs+20−20
@@ -44,46 +44,46 @@ newtype JSXMLHttpRequest = JSXMLHttpRequest JSVal
44
44
45newtype JSXMLHttpRequestClass = JSXMLHttpRequestClass JSVal
45newtype JSXMLHttpRequestClass = JSXMLHttpRequestClass JSVal
46
46
47−newtype GhcjsClientEnv
47+newtype ClientEnv
48− = GhcjsClientEnv
48+ = ClientEnv
49 { baseUrl :: BaseUrl }
49 { baseUrl :: BaseUrl }
50 deriving (Eq, Show)
50 deriving (Eq, Show)
51
51
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)
54
54
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)
60
60
61−instance MonadBase IO GhcjsClientM where
61+instance MonadBase IO ClientM where
62− liftBase = GhcjsClientM . liftBase
62+ liftBase = ClientM . liftBase
63
63
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
66
66
67− liftBaseWith f = GhcjsClientM (liftBaseWith (\g -> f (g . runGhcjsClientM')))
67+ liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . runClientM')))
68
68
69− restoreM st = GhcjsClientM (restoreM st)
69+ restoreM st = ClientM (restoreM st)
70
70
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
74
74
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
79
79
80−instance ClientLike (GhcjsClientM a) (GhcjsClientM a) where
80+instance ClientLike (ClientM a) (ClientM a) where
81 mkClient = id
81 mkClient = id
82
82
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
85
85
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
188
188
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