@@ -21,7 +21,7 @@ import Control.Monad.Reader (MonadReader (..), ReaderT,
21
21
import Control.Monad.Trans (MonadIO (.. ), MonadTrans (.. ))
22
22
import Control.Monad.Trans.Control (ComposeSt , MonadBaseControl (.. ), MonadTransControl (.. ),
23
23
defaultLiftBaseWith , defaultRestoreM )
24
- import Control.Monad.Trans.Resource (MonadResource (.. ), ResourceT , runResourceT )
24
+ import Control.Monad.Trans.Resource (MonadResource (.. ), ResourceT , runResourceT , transResourceT )
25
25
import Network.Wai (Application , Request , Response , ResponseReceived )
26
26
import Prelude ()
27
27
import Prelude.Compat
@@ -197,8 +197,8 @@ instance MonadBaseControl IO DelayedIO where
197
197
liftBaseWith f = DelayedIO $ liftBaseWith $ \ g -> f (g . runDelayedIO')
198
198
restoreM = DelayedIO . restoreM
199
199
200
- runDelayedIO :: DelayedIO a -> Request -> IO (RouteResult a )
201
- runDelayedIO m req = runRouteResultT $ runResourceT $ runReaderT (runDelayedIO' m) req
200
+ runDelayedIO :: DelayedIO a -> Request -> ResourceT IO (RouteResult a )
201
+ runDelayedIO m req = transResourceT runRouteResultT $ runReaderT (runDelayedIO' m) req
202
202
203
203
-- | A 'Delayed' without any stored checks.
204
204
emptyDelayed :: RouteResult a -> Delayed env a
@@ -303,7 +303,7 @@ passToServer Delayed{..} x =
303
303
runDelayed :: Delayed env a
304
304
-> env
305
305
-> Request
306
- -> IO (RouteResult a )
306
+ -> ResourceT IO (RouteResult a )
307
307
runDelayed Delayed {.. } env req =
308
308
runDelayedIO
309
309
(do c <- capturesD env
@@ -325,12 +325,12 @@ runAction :: Delayed env (Handler a)
325
325
-> (RouteResult Response -> IO r )
326
326
-> (a -> RouteResult Response )
327
327
-> IO r
328
- runAction action env req respond k = do
329
- runDelayed action env req >>= go >>= respond
328
+ runAction action env req respond k = runResourceT $ do
329
+ runDelayed action env req >>= go >>= liftIO . respond
330
330
where
331
331
go (Fail e) = return $ Fail e
332
332
go (FailFatal e) = return $ FailFatal e
333
- go (Route a) = do
333
+ go (Route a) = liftIO $ do
334
334
e <- runHandler a
335
335
case e of
336
336
Left err -> return . Route $ responseServantErr err
0 commit comments