]> Git — Sourcephile - haskell/symantic-http.git/blob - symantic-http-demo/client/Main.hs
Remove old stack.yaml
[haskell/symantic-http.git] / symantic-http-demo / client / Main.hs
1 {-# LANGUAGE NoMonomorphismRestriction #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# LANGUAGE Rank2Types #-}
4 {-# LANGUAGE TypeApplications #-}
5 {-# OPTIONS_GHC -fno-warn-orphans #-}
6 {-# OPTIONS_GHC -Wno-missing-signatures #-}
7 module Main where
8 import Data.Maybe (fromJust)
9 import qualified Control.Monad.Classes as MC
10 import qualified Network.HTTP.Client as Client
11 import qualified Pipes as P
12
13 import Symantic.HTTP
14 import Symantic.HTTP.Client
15 import Symantic.HTTP.Pipes ()
16
17 import API (api)
18
19 -- | Derive the callers of the client.
20 client_succ
21 :!: client_countdown
22 = client api
23
24 main :: IO ()
25 main = do
26 manager <- Client.newManager Client.defaultManagerSettings
27 let baseURI = fromJust $ parseURI "http://localhost:8080"
28 let env = clientEnv manager baseURI
29
30 print =<< runClient env (client_succ 42)
31
32 (print =<<) $ runClientStream env (client_countdown 4) $ \pipe ->
33 P.runEffect $
34 P.for pipe $ \i ->
35 MC.exec @IO $ print i