git.iko.soy/typeable/servant
on master help sign in
servant-client-ghcjs: Fixed up README
commite3a11dbcdb53be7b58e4a35a373786c316516658 authorFalco Peijnenburg <falco@lumiguide.nl> dateTue 24 Oct 2017, 21:02 (9 years ago) parentbd52864
1 file changed+11−12
servant-client-ghcjs/README.md+11−12
servant-client-ghcjs/README.md+11−12
@@ -4,7 +4,7 @@ Type safe querying of servant APIs from the browser.
44
55`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.
66
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.
88
99## Using servant-client-ghcjs
1010`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.
1414```haskell
1515{-# LANGUAGE DataKinds #-}
1616{-# LANGUAGE DeriveGeneric #-}
17−{-# LANGUAGE PackageImports #-}
1817{-# LANGUAGE TypeOperators #-}
1918
2019module Main where
2120
22−import "aeson" Data.Aeson
23−import "base" Data.Proxy
24−import "base" GHC.Generics
25−import "servant" Servant.API -- To define the API itself
26−import "servant-client-ghcjs" Servant.Client.Ghcjs -- To generate client functions
21+import Data.Aeson
22+import Data.Proxy
23+import GHC.Generics
24+import Servant.API -- From the 'servant' package, to define the API itself
25+import Servant.Client.Ghcjs -- To generate client functions
2726
2827type API =
2928 "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
129128{-# LANGUAGE TypeApplications #-}
130129
131130...
132−import "servant-client-core" Servant.Client.Core
131+import Servant.Client.Core -- From the 'servant-client-core' package
133132
134133...
135134
@@ -153,7 +152,7 @@ apiClient = APIClient { .. }
153152The call site changes slightly too, as the functions now need to be taken from `apiClient`:
154153
155154```haskell
156−import "servant-client-ghcjs" Servant.Client.Ghcjs
155+import Servant.Client.Ghcjs
157156
158157main :: IO ()
159158main = do
@@ -161,11 +160,11 @@ main = do
161160 print ePos
162161```
163162
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:
165164
166165```haskell
167−import "servant-client" Servant.Client
168−import "http-client" Network.HTTP.Client ( newManager, defaultManagerSettings )
166+import Servant.Client
167+import Network.HTTP.Client ( newManager, defaultManagerSettings )
169168
170169main :: IO ()
171170main = do