on master help sign in
Improving the introduction and ‘README.md’
3845b1cStevenW
Network/HTTP/Req.hs+49−45
@@ -7,73 +7,77 @@
7-- Stability : experimental
7-- Stability : experimental
8-- Portability : portable
8-- Portability : portable
9--
9--
10−-- The documentation below is structured in such a way that most important
10+-- The documentation below is structured in such a way that the most
11−-- information goes first: you learn how to do HTTP requests, then how to
11+-- important information is presented first: you learn how to do HTTP
12−-- embed them in any monad you have, then it goes on giving you details
12+-- requests, how to embed them in any monad you have, and then it gives you
13−-- about less-common things you may want to know about. The documentation is
13+-- details about less-common things you may want to know about. The
14−-- written with sufficient coverage of details and examples, it's designed
14+-- documentation is written with sufficient coverage of details and
15−-- to be a complete tutorial on its own.
15+-- examples, and it's designed to be a complete tutorial on its own.
16--
16--
17-- /(A modest intro goes here, click on 'req' to start making requests.)/
17-- /(A modest intro goes here, click on 'req' to start making requests.)/
18--
18--
19-- === About the library
19-- === About the library
20--
20--
21−-- This is an easy-to-use, type-safe, expandable, high-level HTTP library
21+-- Req is an easy-to-use, type-safe, expandable, high-level HTTP library
22-- that just works without any fooling around.
22-- that just works without any fooling around.
23--
23--
24−-- What does the “easy-to-use” phrase mean? It means that the library is
24+-- What does the phrase “easy-to-use” mean? It means that the library is
25−-- designed to be beginner-friendly, so it's simple to add it to your monad
25+-- designed to be beginner-friendly so it's simple to add to your monad
26-- stack, intuitive to work with, well-documented, and does not get in your
26-- stack, intuitive to work with, well-documented, and does not get in your
27−-- way. Doing HTTP requests is a common task and Haskell library for this
27+-- way. Doing HTTP requests is a common task and a Haskell library for this
28-- should be very approachable and clear to beginners, thus certain
28-- should be very approachable and clear to beginners, thus certain
29-- compromises were made. For example, one cannot currently modify
29-- compromises were made. For example, one cannot currently modify
30−-- 'L.ManagerSettings' of default manager because the library always uses
30+-- 'L.ManagerSettings' of the default manager because the library always
31−-- the same implicit global manager for simplicity and maximal connection
31+-- uses the same implicit global manager for simplicity and maximal
32−-- sharing. There is a way to use your own manager with different settings,
32+-- connection sharing. There is a way to use your own manager with different
33−-- but it requires a bit more typing.
33+-- settings, but it requires a bit more typing.
34--
34--
35-- “Type-safe” means that the library is protective and eliminates certain
35-- “Type-safe” means that the library is protective and eliminates certain
36−-- class of errors. For example, we have correct-by-construction 'Url's,
36+-- classes of errors. For example, we have correct-by-construction 'Url's,
37−-- it's guaranteed that user does not send request body when using methods
37+-- it's guaranteed that the user does not send the request body when using
38−-- like 'GET' or 'OPTIONS', amount of implicit assumptions is minimized by
38+-- methods like 'GET' or 'OPTIONS', and the amount of implicit assumptions
39−-- making user specify his\/her intentions in explicit form (for example,
39+-- is minimized by making the user specify his\/her intentions in an
40−-- it's not possible to avoid specifying body or method of a request).
40+-- explicit form (for example, it's not possible to avoid specifying the
41−-- Authentication methods that assume TLS force user to use TLS on type
41+-- body or method of a request). Authentication methods that assume TLS
42+-- force the user to use TLS at the type level. The library also carefully
42−-- level. The library carefully hides underlying types from lower-level
43+-- hides underlying types from the lower-level @http-client@ package because
43−-- @http-client@ package because it's not safe enough (for example
44+-- those types are not safe enough (for example 'L.Request' is an instance
44−-- 'L.Request' is an instance of 'Data.String.IsString' and if it's
45+-- of 'Data.String.IsString' and, if it's malformed, it will blow up at
45−-- malformed, it will blow up at run-time).
46+-- run-time).
46--
47--
47-- “Expandable” refers to the ability of the library to be expanded without
48-- “Expandable” refers to the ability of the library to be expanded without
48−-- ugly hacking. For example, it's possible to define your own HTTP methods,
49+-- having to resort to ugly hacking. For example, it's possible to define
50+-- your own HTTP methods, create new ways to construct the body of a
49−-- new ways to construct body of request, new authorization options, new
51+-- request, create new authorization options, perform a request in a
50−-- ways to actually perform request and how to represent\/parse response. As
52+-- different way, and create your own methods to parse and represent a
51−-- user extends the library to satisfy his\/her special needs, the new
53+-- response. As a user extends the library to satisfy his\/her special
52−-- solutions work just like built-ins. That said, all common cases are
54+-- needs, the new solutions will work just like the built-ins. However, all
53−-- covered by the library out-of-the-box.
55+-- of the common cases are also covered by the library out-of-the-box.
54--
56--
55-- “High-level” means that there are less details to worry about. The
57-- “High-level” means that there are less details to worry about. The
56−-- library is a result of my experiences as a Haskell consultant, working
58+-- library is a result of my experiences as a Haskell consultant. Working
57−-- for several clients who have very different projects and so the library
59+-- for several clients, who had very different projects, showed me that the
58−-- adapts easily to any particular style of writing Haskell applications.
60+-- library should adapt easily to any particular style of writing Haskell
59−-- For example, some people prefer throwing exceptions, while others are
61+-- applications. For example, some people prefer throwing exceptions, while
60−-- concerned with purity: just define 'handleHttpException' accordingly when
62+-- others are concerned with purity. Just define 'handleHttpException'
61−-- making your monad instance of 'MonadHttp' and it will play seamlessly.
63+-- accordingly when making your monad instance of 'MonadHttp' and it will
62−-- Finally, the library cuts boilerplate considerably and helps write
64+-- play together seamlessly. Finally, the library cuts boilerplate down
63−-- concise, easy to read and maintain code.
65+-- considerably, and helps you write concise, easy to read, and maintainable
66+-- code.
64--
67--
65-- === Using with other libraries
68-- === Using with other libraries
66--
69--
67−-- * You won't need low-level interface of @http-client@ most of the
70+-- * You won't need the low-level interface of @http-client@ most of the
68−-- time, but when you do, it's better import it qualified because it
71+-- time, but when you do, it's better to do a qualified import,
69−-- has naming conflicts with @req@.
72+-- because @http-client@ has naming conflicts with @req@.
70−-- * For streaming of large request bodies see companion package
73+-- * For streaming of large request bodies see the companion package
71-- @req-conduit@: <https://hackage.haskell.org/package/req-conduit>.
74-- @req-conduit@: <https://hackage.haskell.org/package/req-conduit>.
72--
75--
73-- === Lightweight, no risk solution
76-- === Lightweight, no risk solution
74--
77--
75-- The library uses the following mature packages under the hood to
78-- The library uses the following mature packages under the hood to
76−-- guarantee you best experience without bugs or other funny business:
79+-- guarantee you the best experience that doesn't have any bugs or other
80+-- funny business:
77--
81--
78-- * <https://hackage.haskell.org/package/http-client> — low level HTTP
82-- * <https://hackage.haskell.org/package/http-client> — low level HTTP
79-- client used everywhere in Haskell.
83-- client used everywhere in Haskell.
@@ -81,9 +85,9 @@
81-- support for @http-client@.
85-- support for @http-client@.
82--
86--
83-- It's important to note that since we leverage well-known libraries that
87-- It's important to note that since we leverage well-known libraries that
84−-- the whole Haskell ecosystem uses, there is no risk in using @req@, as the
88+-- the whole Haskell ecosystem uses, there is no risk in using @req@. The
85-- machinery for performing requests is the same as with @http-conduit@ and
89-- machinery for performing requests is the same as with @http-conduit@ and
86−-- @wreq@, it's just the API is different.
90+-- @wreq@. The only difference is the API.
87
91
88{-# LANGUAGE CPP #-}
92{-# LANGUAGE CPP #-}
89{-# LANGUAGE DataKinds #-}
93{-# LANGUAGE DataKinds #-}
README.md+41−39
@@ -43,50 +43,52 @@ main = do
43 print (responseBody r :: Value)
43 print (responseBody r :: Value)
44```
44```
45
45
46−This is an easy-to-use, type-safe, expandable, high-level HTTP library that
46+Req is an easy-to-use, type-safe, expandable, high-level HTTP library that
47just works without any fooling around.
47just works without any fooling around.
48
48
49−What does the “easy-to-use” phrase mean? It means that the library is
49+What does the phrase “easy-to-use” mean? It means that the library is
50−designed to be beginner-friendly, so it's simple to add it to your monad
50+designed to be beginner-friendly so it's simple to add to your monad stack,
51−stack, intuitive to work with, well-documented, and does not get in your
51+intuitive to work with, well-documented, and does not get in your way. Doing
52−way. Doing HTTP requests is a common task and Haskell library for this
52+HTTP requests is a common task and a Haskell library for this should be very
53−should be very approachable and clear to beginners, thus certain compromises
53+approachable and clear to beginners, thus certain compromises were made. For
54−were made. For example, one cannot currently modify `ManagerSettings` of
54+example, one cannot currently modify `ManagerSettings` of the default
55−default manager because the library always uses the same implicit global
55+manager because the library always uses the same implicit global manager for
56−manager for simplicity and maximal connection sharing. There is a way to use
56+simplicity and maximal connection sharing. There is a way to use your own
57−your own manager with different settings, but it requires a bit more typing.
57+manager with different settings, but it requires a bit more typing.
58
58
59“Type-safe” means that the library is protective and eliminates certain
59“Type-safe” means that the library is protective and eliminates certain
60−class of errors. For example, we have correct-by-construction URLs, it's
60+classes of errors. For example, we have correct-by-construction URLs, it's
61−guaranteed that user does not send request body when using methods like GET
61+guaranteed that the user does not send the request body when using methods
62−or OPTIONS, amount of implicit assumptions is minimized by making user
62+like GET or OPTIONS, and the amount of implicit assumptions is minimized by
63−specify his/her intentions in explicit form (for example, it's not possible
63+making the user specify his/her intentions in and explicit form (for
64−to avoid specifying body or method of a request). Authentication methods
64+example, it's not possible to avoid specifying the body or method of a
65−that assume TLS force user to use TLS on type level. The library carefully
65+request). Authentication methods that assume TLS force the user to use TLS
66+at the type level. The library also carefully hides underlying types from
66−hides underlying types from lower-level `http-client` package because it's
67+the lower-level `http-client` package because those types are not safe
67−not safe enough (for example `Request` is an instance of `IsString` and if
68+enough (for example `Request` is an instance of `IsString` and, if it's
68−it's malformed, it will blow up at run-time).
69+malformed, it will blow up at run-time).
69−
70+
70−“Expandable” refers to the ability of the library to be expanded without
71+“Expandable” refers to the ability to create new components for dealing with
71−ugly hacking. For example, it's possible to define your own HTTP methods,
72+HTTP without having to resort to ugly hacking. For example, it's possible to
73+define your own HTTP methods, create new ways to construct the body of a
72−new ways to construct body of request, new authorization options, new ways
74+request, create new authorization options, perform a request in a different
73−to actually perform request and how to represent/parse response. As user
75+way, and create your own methods to parse and represent a response. As a
74−extends the library to satisfy his/her special needs, the new solutions work
76+user extends the library to satisfy his/her special needs, the new solutions
75−just like built-ins. That said, all common cases are covered by the library
77+will work just like the built-ins. However, all of the common cases are also
76−out-of-the-box.
78+covered by the library out-of-the-box.
77
79
78“High-level” means that there are less details to worry about. The library
80“High-level” means that there are less details to worry about. The library
79−is a result of my experiences as a Haskell consultant, working for several
81+is a result of my experiences as a Haskell consultant. Working for several
80−clients who have very different projects and so the library adapts easily to
82+clients, who had very different projects, showed me that the library should
81−any particular style of writing Haskell applications. For example, some
83+adapt easily to any particular style of writing Haskell applications. For
82−people prefer throwing exceptions, while others are concerned with purity:
84+example, some people prefer throwing exceptions, while others are concerned
83−just define `handleHttpException` accordingly when making your monad
85+with purity. Just define `handleHttpException` accordingly when making your
84−instance of `MonadHttp` and it will play seamlessly. Finally, the library
86+monad instance of `MonadHttp` and it will play together seamlessly. Finally,
85−cuts boilerplate considerably and helps write concise, easy to read and
87+the library cuts boilerplate down considerably, and helps you write concise,
86−maintain code.
88+easy to read, and maintainable code.
87
89
88The library uses the following mature packages under the hood to guarantee
90The library uses the following mature packages under the hood to guarantee
89−you best experience without bugs or other funny business:
91+you the best experience that doesn't have any bugs or other funny business:
90
92
91* [`http-client`](https://hackage.haskell.org/package/http-client) — low
93* [`http-client`](https://hackage.haskell.org/package/http-client) — low
92 level HTTP client used everywhere in Haskell.
94 level HTTP client used everywhere in Haskell.
@@ -95,9 +97,9 @@ you best experience without bugs or other funny business:
95 TLS (HTTPS) support for `http-client`.
97 TLS (HTTPS) support for `http-client`.
96
98
97It's important to note that since we leverage well-known libraries that the
99It's important to note that since we leverage well-known libraries that the
98−whole Haskell ecosystem uses, there is no risk in using Req, as the
100+whole Haskell ecosystem uses, there is no risk in using Req. The machinery
99−machinery for performing requests is the same as with `http-conduit` and
101+for performing requests is the same as `http-conduit` and Wreq. The only
100−Wreq, it's just the API is different.
102+difference is the API.
101
103
102## Motivation and Req vs other libraries
104## Motivation and Req vs other libraries
103
105