@@ -0,0 +1,46 @@
1+{-# LANGUAGE DataKinds #-}
2+{-# LANGUAGE TypeFamilies #-}
3+{-# LANGUAGE TypeOperators #-}
4+module GS8 where
5+
6+import Control.Monad.Trans.Either
7+import Data.Aeson
8+import Servant
9+import Servant.Client
10+
11+import GS3
12+
13+position :: Int -- ^ value for "x"
14+ -> Int -- ^ value for "y"
15+ -> BaseUrl
16+ -> EitherT ServantError IO Position
17+
18+hello :: Maybe String -- ^ an optional value for "name"
19+ -> BaseUrl
20+ -> EitherT ServantError IO HelloMessage
21+
22+marketing :: ClientInfo -- ^ value for the request body
23+ -> BaseUrl
24+ -> EitherT ServantError IO Email
25+
26+position :<|> hello :<|> marketing = client api
27+
28+baseUrl :: BaseUrl
29+baseUrl = BaseUrl Http "localhost" 8081
30+
31+queries :: EitherT ServantError IO (Position, HelloMessage, Email)
32+queries = do
33+ pos <- position 10 10 baseUrl
34+ msg <- hello (Just "servant") baseUrl
35+ em <- marketing (ClientInfo "Alp" "alp@foo.com" 26 ["haskell", "mathematics"]) baseUrl
36+ return (pos, msg, em)
37+
38+run :: IO ()
39+run = do
40+ res <- runEitherT queries
41+ case res of
42+ Left err -> putStrLn $ "Error: " ++ show err
43+ Right (pos, msg, em) -> do
44+ print pos
45+ print msg
46+ print em