Using servant with ReaderT IO a

后端 未结 3 1016
生来不讨喜
生来不讨喜 2021-02-09 00:02

I\'m using the servant library for my JSON API. I need some help to get a ServerT MyAPI (ReaderT a IO) monad stack working.

Here\'s an example

3条回答
  •  时光说笑
    2021-02-09 00:20

    Recent versions of servant have simplified this a lot. See Using a custom monad in the servant cookbook.

    nt :: State -> AppM a -> Handler a
    nt s x = runReaderT x s
    
    app :: State -> Application
    app s = serve api $ hoistServer api (nt s) server
    

提交回复
热议问题