From de375e26dea4407ab87d624e4d430b7c11e290f5 Mon Sep 17 00:00:00 2001 From: Jeff Happily Date: Sun, 8 Nov 2020 10:55:01 +0800 Subject: [PATCH 1/2] Replace HandlerT with HandlerFor in the documentation --- yesod-core/src/Yesod/Core/Handler.hs | 8 ++++---- yesod-core/src/Yesod/Core/Internal/Run.hs | 12 ++++++------ yesod-core/src/Yesod/Core/Types.hs | 4 ++-- yesod-eventsource/Yesod/EventSource.hs | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/yesod-core/src/Yesod/Core/Handler.hs b/yesod-core/src/Yesod/Core/Handler.hs index b8f82419..063ad1f9 100644 --- a/yesod-core/src/Yesod/Core/Handler.hs +++ b/yesod-core/src/Yesod/Core/Handler.hs @@ -1464,8 +1464,8 @@ respond ct = return . TypedContent ct . toContent -- | Use a @Source@ for the response body. -- --- Note that, for ease of use, the underlying monad is a @HandlerT@. This --- implies that you can run any @HandlerT@ action. However, since a streaming +-- Note that, for ease of use, the underlying monad is a @HandlerFor@. This +-- implies that you can run any @HandlerFor@ action. However, since a streaming -- response occurs after the response headers have already been sent, some -- actions make no sense here. For example: short-circuit responses, setting -- headers, changing status codes, etc. @@ -1476,8 +1476,8 @@ respondSource :: ContentType -> HandlerFor site TypedContent respondSource ctype src = HandlerFor $ \hd -> -- Note that this implementation relies on the fact that the ResourceT - -- environment provided by the server is the same one used in HandlerT. - -- This is a safe assumption assuming the HandlerT is run correctly. + -- environment provided by the server is the same one used in HandlerFor. + -- This is a safe assumption assuming the HandlerFor is run correctly. return $ TypedContent ctype $ ContentSource $ transPipe (lift . flip unHandlerFor hd) src diff --git a/yesod-core/src/Yesod/Core/Internal/Run.hs b/yesod-core/src/Yesod/Core/Internal/Run.hs index ed92f0c0..8f0afee9 100644 --- a/yesod-core/src/Yesod/Core/Internal/Run.hs +++ b/yesod-core/src/Yesod/Core/Internal/Run.hs @@ -181,7 +181,7 @@ evalFallback contents val = catchAny (fmap ((mempty, ) . HCError) . toErrorHandler) -- | Function used internally by Yesod in the process of converting a --- 'HandlerT' into an 'Application'. Should not be needed by users. +-- 'HandlerFor' into an 'Application'. Should not be needed by users. runHandler :: ToTypedContent c => RunHandlerEnv site site -> HandlerFor site c @@ -216,26 +216,26 @@ safeEh log' er req = do (toContent ("Internal Server Error" :: S.ByteString)) (reqSession req) --- | Run a 'HandlerT' completely outside of Yesod. This +-- | Run a 'HandlerFor' completely outside of Yesod. This -- function comes with many caveats and you shouldn't use it -- unless you fully understand what it's doing and how it works. -- -- As of now, there's only one reason to use this function at --- all: in order to run unit tests of functions inside 'HandlerT' +-- all: in order to run unit tests of functions inside 'HandlerFor' -- but that aren't easily testable with a full HTTP request. -- Even so, it's better to use @wai-test@ or @yesod-test@ instead -- of using this function. -- -- This function will create a fake HTTP request (both @wai@'s -- 'Request' and @yesod@'s 'Request') and feed it to the --- @HandlerT@. The only useful information the @HandlerT@ may +-- @HandlerFor@. The only useful information the @HandlerFor@ may -- get from the request is the session map, which you must supply -- as argument to @runFakeHandler@. All other fields contain -- fake information, which means that they can be accessed but -- won't have any useful information. The response of the --- @HandlerT@ is completely ignored, including changes to the +-- @HandlerFor@ is completely ignored, including changes to the -- session, cookies or headers. We only return you the --- @HandlerT@'s return value. +-- @HandlerFor@'s return value. runFakeHandler :: (Yesod site, MonadIO m) => SessionMap -> (site -> Logger) diff --git a/yesod-core/src/Yesod/Core/Types.hs b/yesod-core/src/Yesod/Core/Types.hs index 7d55b358..a33a4f5c 100644 --- a/yesod-core/src/Yesod/Core/Types.hs +++ b/yesod-core/src/Yesod/Core/Types.hs @@ -231,7 +231,7 @@ data GHState = GHState -- | An extension of the basic WAI 'W.Application' datatype to provide extra -- features needed by Yesod. Users should never need to use this directly, as --- the 'HandlerT' monad and template haskell code should hide it away. +-- the 'HandlerFor' monad and template haskell code should hide it away. type YesodApp = YesodRequest -> ResourceT IO YesodResponse -- | A generic widget, allowing specification of both the subsite and master @@ -473,7 +473,7 @@ instance MonadLogger (WidgetFor site) where instance MonadLoggerIO (WidgetFor site) where askLoggerIO = WidgetFor $ return . rheLog . handlerEnv . wdHandler --- Instances for HandlerT +-- Instances for HandlerFor instance Applicative (HandlerFor site) where pure = HandlerFor . const . return (<*>) = ap diff --git a/yesod-eventsource/Yesod/EventSource.hs b/yesod-eventsource/Yesod/EventSource.hs index 21310b19..6e28383e 100644 --- a/yesod-eventsource/Yesod/EventSource.hs +++ b/yesod-eventsource/Yesod/EventSource.hs @@ -63,9 +63,9 @@ sourceToSource src = Just x -> yield (Chunk x) >> yield Flush --- | Return a Server-Sent Event stream given a 'HandlerT' action +-- | Return a Server-Sent Event stream given a 'HandlerFor' action -- that is repeatedly called. A state is threaded for the action --- so that it may avoid using @IORefs@. The @HandlerT@ action +-- so that it may avoid using @IORefs@. The @HandlerFor@ action -- may sleep or block while waiting for more data. The HTTP -- socket is flushed after every list of simultaneous events. -- The connection is closed as soon as an 'ES.CloseEvent' is From 29bb2053fd5933f891733d0b0ac60949c8d81106 Mon Sep 17 00:00:00 2001 From: Jeff Happily Date: Sun, 8 Nov 2020 18:32:33 +0800 Subject: [PATCH 2/2] Bump version and update changelog --- yesod-core/ChangeLog.md | 4 ++++ yesod-core/yesod-core.cabal | 2 +- yesod-eventsource/ChangeLog.md | 4 ++++ yesod-eventsource/yesod-eventsource.cabal | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/yesod-core/ChangeLog.md b/yesod-core/ChangeLog.md index d8564ece..43761f8c 100644 --- a/yesod-core/ChangeLog.md +++ b/yesod-core/ChangeLog.md @@ -1,5 +1,9 @@ # ChangeLog for yesod-core +## 1.6.18.6 + +* Update documentation from `HandlerT` to `HandlerFor` [#1703](https://github.com/yesodweb/yesod/pull/1703) + ## 1.6.18.5 Document `ErrorResponse` [#1698](https://github.com/yesodweb/yesod/pull/1698) diff --git a/yesod-core/yesod-core.cabal b/yesod-core/yesod-core.cabal index d88b0418..6be71633 100644 --- a/yesod-core/yesod-core.cabal +++ b/yesod-core/yesod-core.cabal @@ -1,5 +1,5 @@ name: yesod-core -version: 1.6.18.5 +version: 1.6.18.6 license: MIT license-file: LICENSE author: Michael Snoyman diff --git a/yesod-eventsource/ChangeLog.md b/yesod-eventsource/ChangeLog.md index a5b12741..82290f7a 100644 --- a/yesod-eventsource/ChangeLog.md +++ b/yesod-eventsource/ChangeLog.md @@ -1,3 +1,7 @@ +## 1.6.0.1 + +* Update documentation from `HandlerT` to `HandlerFor` [#1703](https://github.com/yesodweb/yesod/pull/1703) + ## 1.6.0 * Upgrade to yesod-core 1.6.0 diff --git a/yesod-eventsource/yesod-eventsource.cabal b/yesod-eventsource/yesod-eventsource.cabal index fc74bf26..591988f5 100644 --- a/yesod-eventsource/yesod-eventsource.cabal +++ b/yesod-eventsource/yesod-eventsource.cabal @@ -1,5 +1,5 @@ name: yesod-eventsource -version: 1.6.0 +version: 1.6.0.1 license: MIT license-file: LICENSE author: Felipe Lessa