on master help sign in
servant-client-ghcjs: Fixed up README
e3a11dbFalco Peijnenburg
servant-client-ghcjs/README.md+11−12
@@ -4,7 +4,7 @@ Type safe querying of servant APIs from the browser.
4
4
5`servant-client-ghcjs` is much like `servant-client`, as both packages allow you to generate functions that query the endpoints of your servant API. Both packages should feel the same in usage. The big difference lies in how they perform the actual requests. `servant-client` (indirectly) uses your operating system's socket mechanisms, whereas `servant-client-ghcjs` uses your browser's [XHR](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest) mechanisms to send requests.
5`servant-client-ghcjs` is much like `servant-client`, as both packages allow you to generate functions that query the endpoints of your servant API. Both packages should feel the same in usage. The big difference lies in how they perform the actual requests. `servant-client` (indirectly) uses your operating system's socket mechanisms, whereas `servant-client-ghcjs` uses your browser's [XHR](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest) mechanisms to send requests.
6
6
7−This guide assumes knowledge of servant. Reading its [documentation](haskell-servant.readthedocs.io) is recommended if you're new to the subject.
7+This guide assumes knowledge of servant. Reading its [documentation](http://haskell-servant.readthedocs.io) is recommended if you're new to the subject.
8
8
9## Using servant-client-ghcjs
9## Using servant-client-ghcjs
10`servant-client-ghcjs` should feel familiar if you've worked with `servant-client`.
10`servant-client-ghcjs` should feel familiar if you've worked with `servant-client`.
@@ -14,16 +14,15 @@ Take the following API (taken from the [Querying an API](http://haskell-servant.
14```haskell
14```haskell
15{-# LANGUAGE DataKinds #-}
15{-# LANGUAGE DataKinds #-}
16{-# LANGUAGE DeriveGeneric #-}
16{-# LANGUAGE DeriveGeneric #-}
17−{-# LANGUAGE PackageImports #-}
18{-# LANGUAGE TypeOperators #-}
17{-# LANGUAGE TypeOperators #-}
19
18
20module Main where
19module Main where
21
20
22−import "aeson" Data.Aeson
21+import Data.Aeson
23−import "base" Data.Proxy
22+import Data.Proxy
24−import "base" GHC.Generics
23+import GHC.Generics
25−import "servant" Servant.API -- To define the API itself
24+import Servant.API -- From the 'servant' package, to define the API itself
26−import "servant-client-ghcjs" Servant.Client.Ghcjs -- To generate client functions
25+import Servant.Client.Ghcjs -- To generate client functions
27
26
28type API =
27type API =
29 "position" :> Capture "x" Int :> Capture "y" Int :> Get '[JSON] Position
28 "position" :> Capture "x" Int :> Capture "y" Int :> Get '[JSON] Position
@@ -129,7 +128,7 @@ In the example below, the client functions are put in a data type called `APICli
129{-# LANGUAGE TypeApplications #-}
128{-# LANGUAGE TypeApplications #-}
130
129
131...
130...
132−import "servant-client-core" Servant.Client.Core
131+import Servant.Client.Core -- From the 'servant-client-core' package
133
132
134...
133...
135
134
@@ -153,7 +152,7 @@ apiClient = APIClient { .. }
153The call site changes slightly too, as the functions now need to be taken from `apiClient`:
152The call site changes slightly too, as the functions now need to be taken from `apiClient`:
154
153
155```haskell
154```haskell
156−import "servant-client-ghcjs" Servant.Client.Ghcjs
155+import Servant.Client.Ghcjs
157
156
158main :: IO ()
157main :: IO ()
159main = do
158main = do
@@ -161,11 +160,11 @@ main = do
161 print ePos
160 print ePos
162```
161```
163
162
164−Here's how the requests would be performed in regular `servant-client`:
163+Here's how the requests would be performed using the regular `servant-client` package:
165
164
166```haskell
165```haskell
167−import "servant-client" Servant.Client
166+import Servant.Client
168−import "http-client" Network.HTTP.Client ( newManager, defaultManagerSettings )
167+import Network.HTTP.Client ( newManager, defaultManagerSettings )
169
168
170main :: IO ()
169main :: IO ()
171main = do
170main = do