Skip to content

Commit 3d33703

Browse files
authored
Merge pull request #285 from yesodweb/docs-book
Minor fixes till the routing chapter
2 parents 18cf52f + a90bd0d commit 3d33703

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
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.

book/asciidoc/yesod-typeclass.asciidoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ still need to deal with ports. And even if we get the port number from the
4747
request, are we using HTTP or HTTPS? And even if you know _that_, such an
4848
approach would mean that, depending on how the user submitted a request would
4949
generate different URLs. For example, we would generate different URLs
50-
depending if the user connected to "example.com" or "www.example.com". For
50+
depending on if the user connected to "example.com" or "www.example.com". For
5151
Search Engine Optimization, we want to be able to consolidate on a single
5252
canonical URL.
5353

@@ -368,13 +368,13 @@ In fact, you could even use special responses like redirects:
368368
NOTE: Even though you _can_ do this, I don't actually recommend such practices.
369369
A 404 should be a 404.
370370

371-
=== External CSS and Javascript
371+
=== External CSS and JavaScript
372372

373373
NOTE: The functionality described here is automatically included in the scaffolded site, so you don't need to worry about implementing this yourself.
374374

375375
One of the most powerful, and most intimidating, methods in the Yesod typeclass
376376
is +addStaticContent+. Remember that a Widget consists of multiple components,
377-
including CSS and Javascript. How exactly does that CSS/JS arrive in the user's
377+
including CSS and JavaScript. How exactly does that CSS/JS arrive in the user's
378378
browser? By default, they are served in the +<head>+ of the page, inside
379379
+<style>+ and +<script>+ tags, respectively.
380380

@@ -412,7 +412,7 @@ The scaffolded +addStaticContent+ does a number of intelligent things to help
412412
you out:
413413

414414

415-
* It automatically minifies your Javascript using the hjsmin package.
415+
* It automatically minifies your JavaScript using the hjsmin package.
416416
* It names the output files based on a hash of the file contents. This means
417417
you can set your cache headers to far in the future without fears of stale
418418
content.
@@ -461,19 +461,19 @@ Yesod, it's just plain old Haskell. There are three methods involved:
461461
isWriteRequest:: Determine if the current request is a "read" or "write" operations. By default, Yesod follows RESTful principles, and assumes +GET+, +HEAD+, +OPTIONS+, and +TRACE+ requests are read-only, while all others are writable.
462462

463463
isAuthorized:: Takes a route (i.e., type-safe URL) and a boolean indicating whether or not the request is a write request. It returns an +AuthResult+, which can have one of three values:
464-
* +Authorized+
465-
* +AuthenticationRequired+
466-
* +Unauthorized+
464+
* +Authorized+
465+
* +AuthenticationRequired+
466+
* +Unauthorized+
467467

468468
By default, it returns +Authorized+ for all requests.
469469

470470
authRoute:: If +isAuthorized+ returns +AuthenticationRequired+, then redirect
471471
to the given route. If no route is provided (the default), return a 401
472472
``authentication required'' message.
473473

474-
These methods tie in nicely with the yesod-auth package, which is used by the
475-
scaffolded site to provide a number of authentication options, such as OpenID,
476-
Mozilla Persona, email, username and Twitter. We'll cover more concrete
474+
These methods tie in nicely with the yesod-auth package, which is used
475+
by the scaffolded site to provide a number of authentication options,
476+
such as OpenID, email, username and Twitter. We'll cover more concrete
477477
examples in the auth chapter.
478478

479479
=== Some Simple Settings

0 commit comments

Comments
 (0)