2

I have a following problem: I would like a new type of combinator in Servant (let's name it Provide): it would behave similarly to QueryParam, but instead of searching for a given param in a query string and passing it to the handler function, it would provide the value itself. For instance, let's say that we have something like

data Param = First | Second Int

type API = "url" :> Provide Param 'First :> Post '[JSON] SomeResp

server :: Server API
server = handler

handler :: Param -> Handler SomeResp
handler param = ...

so that handler will be always passed First as a param parameter. I know it can be done in other ways (like currying of the handler, etc.), but can it be achieved at the type level of the API itself?

Swordlash
  • 41
  • 1
  • 4
  • As a reference, here is the documentation for how to write custom combinators: https://www.servant.dev/extending.html – Hjulle Sep 22 '20 at 18:16

0 Answers0