Skip to content

Update book content#287

Merged
snoyberg merged 29 commits intoyesodweb:masterfrom
menelaos:update-book-content
Mar 5, 2026
Merged

Update book content#287
snoyberg merged 29 commits intoyesodweb:masterfrom
menelaos:update-book-content

Conversation

@menelaos
Copy link
Contributor

While working through the book, I noticed some outdated content, typos and inconsistencies.
This PR addresses the issues I found. The easiest way to review the changes is probably commit by commit.

import Yesod.Auth
import Yesod.Auth.Email

share [mkPersist sqlSettings { mpsGeneric = False }, mkMigrate "migrateAll"] [persistLowerCase|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mpsGeneric is deprecated and the default value is False anyway.
Cf. yesodweb/persistent#1348

----

We use widgets to compose together HTML, CSS and Javascript. At the end of the
We use widgets to compose together HTML, CSS and JavaScript. At the end of the
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transition from "Javascript" to "JavaScript" was started in #284.

So how exactly do we create a streaming response? Yesod provides a helper
function for this case: +responseSourceDB+. This function takes two arguments:
a content type, and a conduit +Source+ providing a stream of blaze-builder
function for this case: +respondSourceDB+. This function takes two arguments:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was probably a mixup between Yesod's respondSource and responseSource in wai-conduit.

which will automatically restart your application in case it crashes. There are
many great options out there, such as angel or daemontools.

To give a concrete example, here is an Upstart config file. The file must be
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upstart is discontinued so I guess it doesn't make much sense to keep this example.

=== Synopsis

The required dependencies for the below are: persistent, persistent-sqlite and persistent-template.
The required dependencies for the below are: persistent and persistent-sqlite.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

persistent-template has been absorbed into persistent.

But if you want to, you can wrap up the call to +runInputGet+ above using
+handlerToWidget+, and everything will work the same.

=== Performance and error messages
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since HandlerT and WidgetT have been replaced with HandlerFor and WidgetFor, this section is not really applicable anymore. It could be replaced with a section about the design motivations behind the current implementation.

[source, errormsg]
----
No instance for (MonadCRandom e0 (HandlerT App IO))
No instance for 'MonadCRandom e0 (HandlerFor App)'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have changed in recent GHC versions.

+DocId+ into a +Text+ value. Next, we need to be able to convert a stream of
these entities into a stream of events. For this, we can use the built-in
+concatMap+ function from +Data.Conduit.List+: +CL.concatMap entityToEvents+.
+concatMapC+ function from +Conduit+: +concatMapC entityToEvents+.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched to functions from the Conduit module since the use of Data.Conduit.List seems to be discouraged these days.

----

+YesodRunnerEnv+ provides three values: a +Logger+ value for outputting log
+YesodRunnerEnv+ provides several values: a +Logger+ value for outputting log
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yreGen was added in yesodweb/yesod@972e117 and yreGetMaxExpires in yesodweb/yesod@5b4d5ce.

those functionalities.
+HandlerFor+ monad, it's not surprising that there are quite a few functions
that work in that context. +HandlerFor+ is an instance of many common
typeclasses, including +MonadIO+, +MonadUnliftIO+, +MonadLogger+ and
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, thank you! Great updates!

@snoyberg snoyberg merged commit ac1768c into yesodweb:master Mar 5, 2026
@menelaos
Copy link
Contributor Author

menelaos commented Mar 5, 2026

Wow, thank you! Great updates!

Sure! Thank you for the great documentation in the first place!

@menelaos menelaos deleted the update-book-content branch March 5, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants