@@ -311,41 +311,39 @@ import GHC.Exts (Constraint)
312-- > module Main (main) where
312-- > module Main (main) where
314−-- > import Control.Exception (throwIO)
315-- > import Control.Monad
314-- > import Control.Monad
315+-- > import Control.Monad.IO.Class
316-- > import Data.Aeson
316-- > import Data.Aeson
317+-- > import Data.Default.Class
317-- > import Data.Maybe (fromJust)
318-- > import Data.Maybe (fromJust)
318-- > import Data.Monoid ((<>))
319-- > import Data.Monoid ((<>))
319-- > import Data.Text (Text)
320-- > import Data.Text (Text)
320-- > import GHC.Generics
321-- > import GHC.Generics
321-- > import Network.HTTP.Req
322-- > import Network.HTTP.Req
322-- > import qualified Data.ByteString.Char8 as B
323-- > import qualified Data.ByteString.Char8 as B
324−-- > instance MonadHttp IO where
325−-- > handleHttpException = throwIO
327-- We will be making requests against the <https://httpbin.org> service.
325-- We will be making requests against the <https://httpbin.org> service.
329-- Make a GET request, grab 5 random bytes:
327-- Make a GET request, grab 5 random bytes:
331-- > main :: IO ()
329-- > main :: IO ()
332−-- > main = do
330+-- > main = runReq def $ do
333-- > let n :: Int
331-- > let n :: Int
334-- > n = 5
332-- > n = 5
335-- > bs <- req GET (https "httpbin.org" /: "bytes" /~ n) NoReqBody bsResponse mempty
333-- > bs <- req GET (https "httpbin.org" /: "bytes" /~ n) NoReqBody bsResponse mempty
336−-- > B.putStrLn (responseBody bs)
334+-- > liftIO $ B.putStrLn (responseBody bs)
338-- The same, but now we use a query parameter named @\"seed\"@ to control
336-- The same, but now we use a query parameter named @\"seed\"@ to control
339-- seed of the generator:
337-- seed of the generator:
341-- > main :: IO ()
339-- > main :: IO ()
342−-- > main = do
340+-- > main = runReq def $ do
343-- > let n, seed :: Int
341-- > let n, seed :: Int
344-- > n = 5
342-- > n = 5
345-- > seed = 100
343-- > seed = 100
346-- > bs <- req GET (https "httpbin.org" /: "bytes" /~ n) NoReqBody bsResponse $
344-- > bs <- req GET (https "httpbin.org" /: "bytes" /~ n) NoReqBody bsResponse $
347-- > "seed" =: seed
345-- > "seed" =: seed
348−-- > B.putStrLn (responseBody bs)
346+-- > liftIO $ B.putStrLn (responseBody bs)
350-- POST JSON data and get some info about the POST request:
348-- POST JSON data and get some info about the POST request:
@@ -358,27 +356,27 @@ import GHC.Exts (Constraint)
358-- > instance FromJSON MyData
356-- > instance FromJSON MyData
360-- > main :: IO ()
358-- > main :: IO ()
361−-- > main = do
359+-- > main = runReq def $ do
362-- > let myData = MyData
360-- > let myData = MyData
363-- > { size = 6
361-- > { size = 6
364-- > , color = "Green" }
362-- > , color = "Green" }
365-- > v <- req POST (https "httpbin.org" /: "post") (ReqBodyJson myData) jsonResponse mempty
363-- > v <- req POST (https "httpbin.org" /: "post") (ReqBodyJson myData) jsonResponse mempty
366−-- > print (responseBody v :: Value)
364+-- > liftIO $ print (responseBody v :: Value)
368-- Sending URL-encoded body:
366-- Sending URL-encoded body:
370-- > main :: IO ()
368-- > main :: IO ()
371−-- > main = do
369+-- > main = runReq def $ do
372-- > let params =
370-- > let params =
373-- > "foo" =: ("bar" :: Text) <>
371-- > "foo" =: ("bar" :: Text) <>
374-- > queryFlag "baz"
372-- > queryFlag "baz"
375-- > response <- req POST (https "httpbin.org" /: "post") (ReqBodyUrlEnc params) jsonResponse mempty
373-- > response <- req POST (https "httpbin.org" /: "post") (ReqBodyUrlEnc params) jsonResponse mempty
376−-- > print (responseBody response :: Value)
374+-- > liftIO $ print (responseBody response :: Value)
378-- Using various optional parameters and URL that is not known in advance:
376-- Using various optional parameters and URL that is not known in advance:
380-- > main :: IO ()
378-- > main :: IO ()
381−-- > main = do
379+-- > main = runReq def $ do
382-- > -- This is an example of what to do when URL is given dynamically. Of
380-- > -- This is an example of what to do when URL is given dynamically. Of
383-- > -- course in a real application you may not want to use 'fromJust'.
381-- > -- course in a real application you may not want to use 'fromJust'.
384-- > let (url, options) = fromJust (parseUrlHttps "https://httpbin.org/get?foo=bar")
382-- > let (url, options) = fromJust (parseUrlHttps "https://httpbin.org/get?foo=bar")
@@ -388,7 +386,7 @@ import GHC.Exts (Constraint)
388-- > basicAuth "username" "password" <>
386-- > basicAuth "username" "password" <>
389-- > options <> -- contains the ?foo=bar part
387-- > options <> -- contains the ?foo=bar part
390-- > port 443 -- here you can put any port of course
388-- > port 443 -- here you can put any port of course
391−-- > print (responseBody response :: Value)
389+-- > liftIO $ print (responseBody response :: Value)
394 :: ( MonadHttp m
392 :: ( MonadHttp m