on master help sign in
Remove Monoid instance of Link and simplify Utils.Links documentation
3a4471fChristian Marie
src/Servant/Utils/Links.hs+4−9
@@ -28,9 +28,9 @@
28-- 'safeLink'. The first argument to 'safeLink' is a type representing the
28-- 'safeLink'. The first argument to 'safeLink' is a type representing the
29-- endpoint you would like to point to. This will need to end in a verb like
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
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
31+-- ensure the endpoint is within. Further arguments be required depending on
32−-- depending on the type of the endpoint. If everything lines up you will get a
32+-- the type of the endpoint. If everything lines up you will get a 'URI' out
33−-- 'URI' out the other end.
33+-- the other end.
34--
34--
35-- 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,
36-- but types which form part of the URL path like 'Capture' must be included.
36-- but types which form part of the URL path like 'Capture' must be included.
@@ -188,11 +188,6 @@ addMatrixParam param l = l { _segments = f (_segments l) }
188 ArrayElemParam k v -> seg <> ";" <> k <> "[]=" <> escape (unpack v)
188 ArrayElemParam k v -> seg <> ";" <> k <> "[]=" <> escape (unpack v)
189 FlagParam k -> seg <> ";" <> k
189 FlagParam k -> seg <> ";" <> k
190
190
191−instance Monoid Link where
192− mempty = Link mempty mempty
193− mappend (Link a1 b1) (Link a2 b2) =
194− Link (a1 <> a2) (b1 <> b2)
195−
196linkURI :: Link -> URI
191linkURI :: Link -> URI
197linkURI (Link segments q_params) =
192linkURI (Link segments q_params) =
198 URI mempty -- No scheme (relative)
193 URI mempty -- No scheme (relative)
@@ -221,7 +216,7 @@ safeLink
221 => Proxy endpoint -- ^ The API endpoint you would like to point to
216 => Proxy endpoint -- ^ The API endpoint you would like to point to
222 -> Proxy api -- ^ The whole API that you this endpoint is a part of
217 -> Proxy api -- ^ The whole API that you this endpoint is a part of
223 -> MkLink endpoint
218 -> MkLink endpoint
224−safeLink endpoint _ = link endpoint mempty
219+safeLink endpoint _ = link endpoint (Link mempty mempty)
225
220
226-- | Construct a link for an endpoint.
221-- | Construct a link for an endpoint.
227class HasLink endpoint where
222class HasLink endpoint where