on master help sign in
Utils.Link documentation cleanup
c1ab495Christian Marie
src/Servant/Utils/Links.hs+10−11
@@ -25,23 +25,22 @@
25-- >>> let api = Proxy :: Proxy API
25-- >>> let api = Proxy :: Proxy API
26--
26--
27-- It is possible to generate links that are guaranteed to be within 'API' with
27-- It is possible to generate links that are guaranteed to be within 'API' with
28−-- 'safeLink'.
29−--
30−-- The first argument to 'safeLink' is a symbol representing the endpoint you
28+-- 'safeLink'. The first argument to 'safeLink' is a type representing the
31−-- would like to point to. This will need to end in a verb like Get, or Post.
29+-- endpoint you would like to point to. This will need to end in a verb like
30+-- Get, or Post. The second argument is the API in which you would like to
31+-- ensure the endpoint is within. Further arguments may or may not be required
32+-- depending on the type of the endpoint. If everything lines up you will get a
33+-- 'URI' out the other end.
32--
34--
33-- You may omit 'QueryParam's and the like should you not want to provide them,
35-- You may omit 'QueryParam's and the like should you not want to provide them,
34−-- but certain other types like 'Capture' must be included.
36+-- but types which form part of the URL path like 'Capture' must be included.
35−--
36-- The reason you may want to omit 'QueryParam's is that safeLink is a bit
37-- The reason you may want to omit 'QueryParam's is that safeLink is a bit
37-- magical: if parameters are included that could take input it will return a
38-- magical: if parameters are included that could take input it will return a
38−-- function that accepts that input and generates a link.
39+-- function that accepts that input and generates a link. This is best shown
39−--
40−-- This is best shown with an example. Here, a link is generated with no
40+-- with an example. Here, a link is generated with no parameters:
41−-- parameters:
42--
41--
43-- >>> let hello = Proxy :: Proxy ("hello" :> Get Int)
42-- >>> let hello = Proxy :: Proxy ("hello" :> Get Int)
44−-- >>> print $ safeLink hello api
43+-- >>> print (safeLink hello api :: URI)
45-- hello
44-- hello
46--
45--
47-- If the API has an endpoint with parameters then we can generate links with
46-- If the API has an endpoint with parameters then we can generate links with