Skip to content

Commit a90bd0d

Browse files
committed
Update routing and handlers chapter
1 parent cfc61e7 commit a90bd0d

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

book/asciidoc/routing-and-handlers.asciidoc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -324,30 +324,27 @@ Yesod libraries. Instead, the libraries provide the data type:
324324

325325
[source, haskell]
326326
----
327-
data HandlerT site m a
327+
data HandlerFor site a
328328
----
329329

330-
And like +WidgetT+, this has three arguments: a base monad +m+, a monadic value
331-
+a+, and the foundation data type +site+. Each application defines a +Handler+
332-
synonym which constrains +site+ to that application's foundation data type, and
333-
sets +m+ to +IO+. If your foundation is +MyApp+, in other words, you'd have the
330+
And like +WidgetFor+, this has two arguments: a monadic value +a+, and
331+
the foundation data type +site+. Each application defines a +Handler+
332+
synonym which constrains +site+ to that application's foundation data
333+
type. If your foundation is +MyApp+, in other words, you'd have the
334334
synonym:
335335

336336
[source, haskell]
337337
----
338-
type Handler = HandlerT MyApp IO
338+
type Handler = HandlerFor MyApp
339339
----
340340

341-
We need to be able to modify the underlying monad when writing subsites, but
342-
otherwise we'll use +IO+.
343-
344-
The +HandlerT+ monad provides access to information about the user request
341+
The +HandlerFor+ monad provides access to information about the user request
345342
(e.g. query-string parameters), allows modifying the response (e.g., response
346343
headers), and more. This is the monad that most of your Yesod code will live
347344
in.
348345

349-
In addition, there's a type class called +MonadHandler+. Both +HandlerT+ and
350-
+WidgetT+ are instances of this type class, allowing many common functions to
346+
In addition, there's a type class called +MonadHandler+. Both +HandlerFor+ and
347+
+WidgetFor+ are instances of this type class, allowing many common functions to
351348
be used in both monads. If you see +MonadHandler+ in any API documentation, you
352349
should remember that the function can be used in your +Handler+ functions.
353350

@@ -546,7 +543,7 @@ expiresAt:: Sets the Expires header to the specified date/time.
546543

547544
=== I/O and debugging
548545

549-
The +HandlerT+ and +WidgetT+ monad transformers are both instances of a number
546+
The +HandlerFor+ and +WidgetFor+ monad transformers are both instances of a number
550547
of typeclasses. For this section, the important typeclasses are +MonadIO+ and
551548
+MonadLogger+. The former allows you to perform arbitrary +IO+ actions inside
552549
your handler, such as reading from a file. In order to achieve this, you just
@@ -558,7 +555,7 @@ sent. By default, logs are sent to standard output, in development all messages
558555
are logged, and in production, warnings and errors are logged.
559556

560557
Often times when logging, we want to know where in the source code the logging
561-
occured. For this, +MonadLogger+ provides a number of convenience Template
558+
occurred. For this, +MonadLogger+ provides a number of convenience Template
562559
Haskell functions which will automatically insert source code location into the
563560
log messages. These functions are +$logDebug+, +$logInfo+, +$logWarn+, and
564561
+$logError+. Let's look at a short example of some of these functions.

0 commit comments

Comments
 (0)