úÎ%Å$ÆNone +,:DQRTGet the endpoint with given index in the all-flat representation of the API type.vGet the endpoints with given indices in the all-flat representation of the API type, glueing them together with .NHelper type family that "enumerates" the different endpoints left to right. Reassociates  to the right.†Completely flattens an API type by applying a few simple transformations. The goal is to end up with an API type where things like a   (b  c) are rewritten to a   b  a   cN, so as to have client with very simple types, instead of "nested clients".0Flatten and transform the API type a little bit. Flatten (a   to) an API type.¥This performs a number of transformations on the API type so as to end up with all combinators distributed over endpoints. For example, the following API type:  type API =   "foo"     (   "bar"     (  '[]     '[]      '[]   )   '[]   )   '[] [ ] gets transformed into:    "foo"       "bar"      '[]      "foo"       "bar"      '[JSON]      '[]      "foo"      '[]     '[] [ ] nThe main point of doing this is to avoid "nested types" for server-side handlers and client functions. See  phttps://haskell-servant.readthedocs.io/en/stable/cookbook/structuring-apis/StructuringApis.html#structuring-apisthis cookbook recipe (particularly the notes on  FactoringAPI ) for more about "nested types".:To derive "flat" client functions for the API type above, API , you can do:  getfoobar  postfoobar  getfoo  getstrings = client $  (  ::   API) NTo serve an implementation for that API with "flat" handler types, you can do: € -- we define all our handlers assuming all the arguments are distributed, -- and declare that this is an implementation for Flat API, not API. server :: Server (> API) server = (foo bar -> return $ show (foo + bar)) < (foo bar body -> return $ show (foo + bar - body^2)) ! (foo -> return (foo * 2)) ' (return ["hello", "world"]) api ::   API api =   main :: < () main = Network.Wai.Handler.Warp.run 8080 $ serve ( api) server         !*servant-flatten-0.2-F5fEvWvg1rO4VbSrr77NuPServant.API.FlattenNthNths ReassocBranchReassocRedexFlattenFlatflatten#servant-0.13-3QP0lLoTXqDB1XZ9VIFDC3Servant.API.Alternative:<|>Servant.API.Sub:>base Data.ProxyProxyServant.API.CaptureCaptureghc-prim GHC.TypesIntGHC.BaseStringServant.API.VerbsGetServant.API.ContentTypesJSONServant.API.ReqBodyReqBodyPostIO