Every one of our Yesod applications requires an instance of the
Yesod typeclass. So far, we’ve only seen
defaultLayout. In this chapter, we’ll explore the meaning of many of the methods of
Yesod typeclass gives us a central place for defining
settings for our application. Everything else has a default definition that is usually the right
thing. But in order to build a powerful, customized application, you’ll usually end up wanting
to override at least a few of these methods.
We’ve already mentioned how Yesod is able to automatically render type-safe URLs into a textual URL that can be inserted into an HTML page. Let’s say we have a route definition that looks like:
If we place
SomePathR into a hamlet template, how does Yesod render
it? Yesod always tries to construct absolute URLs. This is especially
useful once we start creating XML sitemaps and Atom feeds, or sending emails. But in
order to construct an absolute URL, we need to know the domain name of the
You might think we could get that information from the user’s request, but we still need to deal with ports. And even if we get the port number from the request, are we using HTTP or HTTPS? And even if you know that, such an approach would mean that different URLs would be generated depending on how the user submitted a request. For example, we would generate different URLs depending on ...