Documentation fixes

This commit is contained in:
Julian K. Arni 2017-09-13 16:01:31 -04:00
parent d6aee29be1
commit da8337809b
6 changed files with 18 additions and 16 deletions

View file

@ -128,15 +128,15 @@ That's it. Let's now write some code that uses our client functions.
``` haskell ``` haskell
queries :: ClientM (Position, HelloMessage, Email) queries :: ClientM (Position, HelloMessage, Email)
queries = do queries = do
pos <- position 10 10 pos <- position 10 10
message <- hello (Just "servant") message <- hello (Just "servant")
em <- marketing (ClientInfo "Alp" "alp@foo.com" 26 ["haskell", "mathematics"]) em <- marketing (ClientInfo "Alp" "alp@foo.com" 26 ["haskell", "mathematics"])
return (pos, message, em) return (pos, message, em)
run :: IO () run :: IO ()
run = do run = do
manager <- newManager defaultManagerSettings manager' <- newManager defaultManagerSettings
res <- runClientM queries (ClientEnv manager (BaseUrl Http "localhost" 8081 "")) res <- runClientM queries (ClientEnv manager' (BaseUrl Http "localhost" 8081 ""))
case res of case res of
Left err -> putStrLn $ "Error: " ++ show err Left err -> putStrLn $ "Error: " ++ show err
Right (pos, message, em) -> do Right (pos, message, em) -> do

View file

@ -1,5 +1,6 @@
# Revision history for servant-client-core # Revision history for servant-client-core
## 0.11 -- YYYY-mm-dd ## 0.12 -- YYYY-mm-dd
* First version. Released on an unsuspecting world. * First version. Factored out of servant-client all the functionality that was
independent of the http-client backend.

View file

@ -10,7 +10,7 @@ This library should mainly be of interest to backend- and combinator-writers.
If you are creating a new backend, you'll need to: If you are creating a new backend, you'll need to:
1. Define a `RunClient` instance for your datatype (call it 'MyMonad') 1. Define a `RunClient` instance for your datatype (call it `MyMonad`)
2. Define a `ClientLike` instance. This will look like: 2. Define a `ClientLike` instance. This will look like:
``` haskell ``` haskell

View file

@ -51,14 +51,15 @@ library
, text >= 1.2 && < 1.3 , text >= 1.2 && < 1.3
hs-source-dirs: src hs-source-dirs: src
default-language: Haskell2010 default-language: Haskell2010
include-dirs: include ghc-options: -Wall
include-dirs: include
test-suite spec test-suite spec
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
ghc-options: -Wall ghc-options: -Wall
default-language: Haskell2010 default-language: Haskell2010
hs-source-dirs: test hs-source-dirs: test
main-is: Spec.hs main-is: Spec.hs
build-depends: build-depends:
base base
, base-compat , base-compat

View file

@ -6,8 +6,8 @@ module Servant.Client
, ClientM , ClientM
, runClientM , runClientM
, ClientEnv(..) , ClientEnv(..)
, module X , module Servant.Client.Core.Reexport
) where ) where
import Servant.Client.Internal.HttpClient import Servant.Client.Internal.HttpClient
import Servant.Client.Core.Reexport as X import Servant.Client.Core.Reexport

View file

@ -65,7 +65,7 @@ client :: HasClient ClientM api => Proxy api -> Client ClientM api
client api = api `clientIn` (Proxy :: Proxy ClientM) client api = api `clientIn` (Proxy :: Proxy ClientM)
-- | @ClientM@ is the monad in which client functions run. Contains the -- | @ClientM@ is the monad in which client functions run. Contains the
-- 'Manager' and 'BaseUrl' used for requests in the reader environment. -- 'Client.Manager' and 'BaseUrl' used for requests in the reader environment.
newtype ClientM a = ClientM newtype ClientM a = ClientM
{ runClientM' :: ReaderT ClientEnv (ExceptT ServantError IO) a } { runClientM' :: ReaderT ClientEnv (ExceptT ServantError IO) a }
deriving ( Functor, Applicative, Monad, MonadIO, Generic deriving ( Functor, Applicative, Monad, MonadIO, Generic