git.iko.soy/typeable/servant
on master help sign in
Add NamedRoutes combinator

Allows users to directly embed APIs defined as records of routes into vanilla Servant API types. E.g.: ```haskell data MyRoutes mode = MyRoutes { version :: mode :- Get '[JSON] Int , … } type API = "prefix" :> NamedRoutes MyRoutes :<|> … ``` APIs can thus be recursively defined directly with Generic record types.

commit65e3070cacccb02502e8c24b3222a0532e3f4397 authorGaël Deest <gael.deest@tweag.io> dateThu 30 Sep 2021, 18:16 (5 years ago) parent04e4de5
1 file changed+5
servant/src/Servant/API/Generic.hs+5
servant/src/Servant/API/Generic.hs+5
@@ -37,6 +37,8 @@ module Servant.API.Generic (
3737 ToServant,
3838 toServant,
3939 fromServant,
40+ -- * NamedRoutes combinator
41+ NamedRoutes,
4042 -- * AsApi
4143 AsApi,
4244 ToServantApi,
@@ -120,6 +122,9 @@ genericApi
120122 -> Proxy (ToServantApi routes)
121123genericApi _ = Proxy
122124
125+-- | Combinator for embedding a record of named routes into a Servant API type.
126+data NamedRoutes (api :: * -> *)
127+
123128-------------------------------------------------------------------------------
124129-- Class
125130-------------------------------------------------------------------------------