You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been experimenting MonadUnliftIO handlers under Servant with some success. Example. An essential component is unliftio's "toIO" function which looks like this:
toIO :: MonadUnliftIO m => m a -> m (IO a)
This is an effective way to get a IO a which with a little further massaging can be turned into Handler. But, this function has a monadic context so it does not work with hoistServer which has this signature:
hoistServer :: HasServer api '[] => Proxy api -> (forall x. m x -> n x) -> ServerT api m -> ServerT api n
What is needed in this situation is a monadic version of hoistServer that looks like this:
hoistServerM :: HasServer api '[] => Proxy api -> (forall x. m x -> m (n x)) -> ServerT api m -> m (ServerT api n)
I would like to experiment with an implementation that looks like this:
Convert the existing implementations of hoistServerWithContext into hoistServerWithContextM.
Add a hoistServerWithContext that wraps hoistServerWithContextM using Identity.
My example above demonstrates ReaderT, but my real motive is to enable ReaderT-based effect systems like cleff and effectful.
I am looking for some feedback on this idea. If I did a PR like this would it have any hope of being merged? Are there some obvious shortcomings here that I am not seeing?
As a reference, wai supports unliftio through the wai-control package.
Thank you for your time.
The text was updated successfully, but these errors were encountered:
I have been experimenting
MonadUnliftIO
handlers under Servant with some success. Example. An essential component isunliftio
's "toIO
" function which looks like this:This is an effective way to get a
IO a
which with a little further massaging can be turned intoHandler
. But, this function has a monadic context so it does not work withhoistServer
which has this signature:What is needed in this situation is a monadic version of hoistServer that looks like this:
I would like to experiment with an implementation that looks like this:
hoistServerWithContext
intohoistServerWithContextM
.hoistServerWithContext
that wrapshoistServerWithContextM
usingIdentity
.My example above demonstrates
ReaderT
, but my real motive is to enableReaderT
-based effect systems likecleff
andeffectful
.I am looking for some feedback on this idea. If I did a PR like this would it have any hope of being merged? Are there some obvious shortcomings here that I am not seeing?
As a reference, wai supports
unliftio
through the wai-control package.Thank you for your time.
The text was updated successfully, but these errors were encountered: