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