git.iko.soy/typeable/servant
on master help sign in
Add doctests (and changelog)
2779f52Oleg Grenrus
servant/CHANGELOG.md+2
@@ -30,6 +30,8 @@
30 [#767](https://github.com/haskell-servant/servant/pull/767)
30 [#767](https://github.com/haskell-servant/servant/pull/767)
31 [#790](https://github.com/haskell-servant/servant/pull/790)
31 [#790](https://github.com/haskell-servant/servant/pull/790)
32 [#788](https://github.com/haskell-servant/servant/pull/788))
32 [#788](https://github.com/haskell-servant/servant/pull/788))
33+- Add `addLinks` to generate all links for unnested APIs.
34+ ([#851](https://github.com/haskell-servant/servant/pull/851))
33- Allow newest dependencies
35- Allow newest dependencies
34 ([#772](https://github.com/haskell-servant/servant/pull/772)
36 ([#772](https://github.com/haskell-servant/servant/pull/772)
35 [#842](https://github.com/haskell-servant/servant/pull/842))
37 [#842](https://github.com/haskell-servant/servant/pull/842))
servant/src/Servant/Utils/Links.hs+15
@@ -226,6 +226,20 @@ safeLink _ endpoint = toLink endpoint (Link mempty mempty)
226--
226--
227-- Note that the @api@ type must be restricted to the endpoints that have
227-- Note that the @api@ type must be restricted to the endpoints that have
228-- valid links to them.
228-- valid links to them.
229+--
230+-- >>> type API = "foo" :> Capture "name" Text :> Get '[JSON] Text :<|> "bar" :> Capture "name" Int :> Get '[JSON] Double
231+-- >>> let fooLink :<|> barLink = allLinks (Proxy :: Proxy API)
232+-- >>> :t fooLink
233+-- fooLink :: Text -> Link
234+-- >>> :t barLink
235+-- barLink :: Int -> Link
236+--
237+-- Note: nested APIs don't work well with this approach
238+--
239+-- >>> :kind! MkLink (Capture "nest" Char :> (Capture "x" Int :> Get '[JSON] Int :<|> Capture "y" Double :> Get '[JSON] Double))
240+-- MkLink (Capture "nest" Char :> (Capture "x" Int :> Get '[JSON] Int :<|> Capture "y" Double :> Get '[JSON] Double)) :: *
241+-- = Char -> (Int -> Link) :<|> (Double -> Link)
242+--
229allLinks
243allLinks
230 :: forall api. HasLink api
244 :: forall api. HasLink api
231 => Proxy api
245 => Proxy api
@@ -330,3 +344,4 @@ instance HasLink sub => HasLink (AuthProtect tag :> sub) where
330
344
331-- $setup
345-- $setup
332-- >>> import Servant.API
346-- >>> import Servant.API
347+-- >>> import Data.Text (Text)