Hoogle Search

Within LTS Haskell 24.13 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. handlerToIO :: MonadIO m => HandlerFor site (HandlerFor site a -> m a)

    yesod-core Yesod.Core.Handler

    Returns a function that runs HandlerFor actions inside IO. Sometimes you want to run an inner HandlerFor action outside the control flow of an HTTP request (on the outer HandlerFor action). For example, you may want to spawn a new thread:

    getFooR :: Handler RepHtml
    getFooR = do
    runInnerHandler <- handlerToIO
    liftIO $ forkIO $ runInnerHandler $ do
    Code here runs inside HandlerFor but on a new thread.
    This is the inner HandlerFor.
    ...
    Code here runs inside the request's control flow.
    This is the outer HandlerFor.
    ...
    
    Another use case for this function is creating a stream of server-sent events using HandlerFor actions (see yesod-eventsource). Most of the environment from the outer HandlerFor is preserved on the inner HandlerFor, however:
    • The request body is cleared (otherwise it would be very difficult to prevent huge memory leaks).
    • The cache is cleared (see cached).
    Changes to the response made inside the inner HandlerFor are ignored (e.g., session variables, cookies, response headers). This allows the inner HandlerFor to outlive the outer HandlerFor (e.g., on the forkIO example above, a response may be sent to the client without killing the new thread).

  2. handlerToIO :: MonadIO m => HandlerFor site (HandlerFor site a -> m a)

    hledger-web Hledger.Web.Import

    Returns a function that runs HandlerFor actions inside IO. Sometimes you want to run an inner HandlerFor action outside the control flow of an HTTP request (on the outer HandlerFor action). For example, you may want to spawn a new thread:

    getFooR :: Handler RepHtml
    getFooR = do
    runInnerHandler <- handlerToIO
    liftIO $ forkIO $ runInnerHandler $ do
    Code here runs inside HandlerFor but on a new thread.
    This is the inner HandlerFor.
    ...
    Code here runs inside the request's control flow.
    This is the outer HandlerFor.
    ...
    
    Another use case for this function is creating a stream of server-sent events using HandlerFor actions (see yesod-eventsource). Most of the environment from the outer HandlerFor is preserved on the inner HandlerFor, however:
    • The request body is cleared (otherwise it would be very difficult to prevent huge memory leaks).
    • The cache is cleared (see cached).
    Changes to the response made inside the inner HandlerFor are ignored (e.g., session variables, cookies, response headers). This allows the inner HandlerFor to outlive the outer HandlerFor (e.g., on the forkIO example above, a response may be sent to the client without killing the new thread).

  3. handlerToIO :: MonadIO m => HandlerFor site (HandlerFor site a -> m a)

    classy-prelude-yesod ClassyPrelude.Yesod

    Returns a function that runs HandlerFor actions inside IO. Sometimes you want to run an inner HandlerFor action outside the control flow of an HTTP request (on the outer HandlerFor action). For example, you may want to spawn a new thread:

    getFooR :: Handler RepHtml
    getFooR = do
    runInnerHandler <- handlerToIO
    liftIO $ forkIO $ runInnerHandler $ do
    Code here runs inside HandlerFor but on a new thread.
    This is the inner HandlerFor.
    ...
    Code here runs inside the request's control flow.
    This is the outer HandlerFor.
    ...
    
    Another use case for this function is creating a stream of server-sent events using HandlerFor actions (see yesod-eventsource). Most of the environment from the outer HandlerFor is preserved on the inner HandlerFor, however:
    • The request body is cleared (otherwise it would be very difficult to prevent huge memory leaks).
    • The cache is cleared (see cached).
    Changes to the response made inside the inner HandlerFor are ignored (e.g., session variables, cookies, response headers). This allows the inner HandlerFor to outlive the outer HandlerFor (e.g., on the forkIO example above, a response may be sent to the client without killing the new thread).

Page 1 of 1