Skip to content

Commit

Permalink
Apply automatic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg authored and github-actions[bot] committed Dec 20, 2024
1 parent cf74f36 commit 18cf52f
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 72 deletions.
8 changes: 4 additions & 4 deletions public/book-1.6/basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>Routing</h1>
&quot;GET&quot; -&gt; getHomeR
_ -&gt; badMethod

type Handler = HandlerT HelloWorld IO</code></pre>
type Handler = HandlerFor HelloWorld</code></pre>
<aside class="note"><p>In addition to using <code>-ddump-splices</code>, it can often be useful to generate
Haddock documentation for your application to see which functions and data
types were generated for you.</p></aside>
Expand Down Expand Up @@ -154,10 +154,10 @@ <h1>Handler function</h1>
<code>whamlet</code> is another quasi-quoter. In this case, it converts Hamlet syntax into
a Widget. Hamlet is the default HTML templating engine in Yesod. Together with
its siblings Cassius, Lucius and Julius, you can create HTML, CSS and
Javascript in a fully type-safe and compile-time-checked manner. We’ll see much
JavaScript in a fully type-safe and compile-time-checked manner. We’ll see much
more about this in the Shakespeare chapter.</p>
<p>Widgets are another cornerstone of Yesod. They allow you to create modular
components of a site consisting of HTML, CSS and Javascript and reuse them
components of a site consisting of HTML, CSS and JavaScript and reuse them
throughout your site. We’ll get into more detail on them in the widgets
chapter.</p>
</section>
Expand Down Expand Up @@ -204,7 +204,7 @@ <h1>Running</h1>
<p>Once again we mention <code>HelloWorld</code> in our main function. Our foundation
contains all the information we need to route and respond to requests in our
application; now we just need to convert it into something that can run. A
useful function for this in Yesod is <code>warp</code>, which runs the Warp webserver with
useful function for this in Yesod is <code>warp</code>, which runs the Warp web server with
a number of default settings enabled on the specified port (here, it’s 3000).</p>
<p>One of the features of Yesod is that you aren’t tied down to a single
deployment strategy. Yesod is built on top of the Web Application Interface
Expand Down
6 changes: 3 additions & 3 deletions public/book-1.6/haskell.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</li>
</ul>
<p>Additionally, there are a number of great articles on
<a href="https://www.fpcomplete.com/school">School of Haskell</a>.</p>
<a href="https://tech.fpcomplete.com/haskell/learn/">FP Complete’s Haskell’s hub</a>.</p>
<p>In order to use Yesod, you’re going to have to know at least the basics of
Haskell. Additionally, Yesod uses some features of Haskell that aren’t covered
in most introductory texts. While this book assumes the reader has a basic
Expand Down Expand Up @@ -150,7 +150,7 @@ <h1>Language Pragmas</h1>
</li>
</ul>
<p>I personally never use the GHC command line argument approach. It’s a personal
preference, but I like to have my settings clearly stated in a file. In general
preference, but I like to have my settings clearly stated in a file. In general,
it’s recommended to avoid putting extensions in your <code>cabal</code> file; however,
this rule mostly applies when writing publicly available libraries. When you’re
writing an application that you and your team will be working on, having all of
Expand Down Expand Up @@ -281,7 +281,7 @@ <h1>Template Haskell</h1>
<p>A nice trick is that TH code is allowed to perform arbitrary <code>IO</code> actions, and
therefore we can place some input in external files and have it parsed at
compile time. One example usage is to have compile-time checked HTML, CSS, and
Javascript templates.</p>
JavaScript templates.</p>
<p>If your Template Haskell code is being used to generate declarations, and is
being placed at the top level of our file, we can leave off the dollar sign and
parentheses. In other words:</p>
Expand Down
2 changes: 1 addition & 1 deletion public/book-1.6/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
process a more pleasant one. As a community, we have continually pushed new
techniques to try and solve some of the lingering difficulties of security
threats, the stateless nature of HTTP, the multiple languages (HTML, CSS,
Javascript) necessary to create a powerful web application, and more.</p>
JavaScript) necessary to create a powerful web application, and more.</p>
<p>Yesod attempts to ease the web development process by playing to the strengths
of the Haskell programming language. Haskell’s strong compile-time guarantees
of correctness not only encompass types; referential transparency ensures that
Expand Down
16 changes: 8 additions & 8 deletions public/book-1.6/shakespearean-templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


<p>Yesod uses the Shakespearean family of template languages as its standard
approach to HTML, CSS and Javascript creation. This language family shares some
approach to HTML, CSS and JavaScript creation. This language family shares some
common syntax, as well as overarching principles:</p>
<ul>
<li>
Expand Down Expand Up @@ -45,7 +45,7 @@ <h1>Synopsis</h1>
Cassius are both whitespace-sensitive formats, using indentation to denote
nesting. By contrast, Lucius is a superset of CSS, keeping CSS’s braces for
denoting nesting. Julius is a simple passthrough language for producing
Javascript; the only added feature is variable interpolation.</p>
JavaScript; the only added feature is variable interpolation.</p>
<aside class="note"><p>Cassius is in fact just an alternate syntax for Lucius. They both use the
same processing engine underneath, but Cassius files have indentation converted
into braces before processing. The choice between the two is purely one of
Expand Down Expand Up @@ -90,7 +90,7 @@ <h1>Cassius (CSS)</h1>
background-image: url(@{MyBackgroundR})</code></pre>
</section>
<section id="shakespearean-templates_julius_javascript">
<h1>Julius (Javascript)</h1>
<h1>Julius (JavaScript)</h1>
<p>String interpolation works slightly differently in Julius. This is important
from a security standpoint — all interpolated values are valid JSON by default
which helps prevent XSS attacks. You’ll need to use the <code>rawJS</code> function to get
Expand Down Expand Up @@ -229,7 +229,7 @@ <h1>Type-safe URLs</h1>
<h1>Syntax</h1>
<p>All Shakespearean languages share the same interpolation syntax, and are able
to utilize type-safe URLs. They differ in the syntax specific for their target
language (HTML, CSS, or Javascript). Let’s explore each language in turn.</p>
language (HTML, CSS, or JavaScript). Let’s explore each language in turn.</p>
<section id="shakespearean-templates_hamlet_syntax">
<h1>Hamlet Syntax</h1>
<p>Hamlet is the most sophisticated of the languages. Not only does it provide
Expand Down Expand Up @@ -617,11 +617,11 @@ <h1>Cassius Syntax</h1>
<section id="shakespearean-templates_julius_syntax">
<h1>Julius Syntax</h1>
<p>Julius is the simplest of the languages discussed here. In fact, some might
even say it’s really just Javascript. Julius allows the three forms of
even say it’s really just JavaScript. Julius allows the three forms of
interpolation we’ve mentioned so far, and otherwise applies no transformations
to your content.</p>
<aside class="note"><p>If you use Julius with the scaffolded Yesod site, you may notice that
your Javascript is automatically minified. This is not a feature of Julius;
your JavaScript is automatically minified. This is not a feature of Julius;
instead, Yesod uses the hjsmin package to minify Julius output.</p></aside>
</section>
</section>
Expand Down Expand Up @@ -790,7 +790,7 @@ <h1>Alternate Hamlet Types</h1>
<p>
We use a different set of functions, prefixed with an &quot;s&quot;. So the quasiquoter
is <code>shamlet</code> and the external file function is <code>shamletFile</code>. How we
pronounce those is still up for debate.
pronounce this is still up for debate.
</p>
</li>
<li>
Expand Down Expand Up @@ -881,7 +881,7 @@ <h1>Alternate Hamlet Types</h1>
</section>
<section id="shakespearean-templates_other_shakespeare">
<h1>Other Shakespeare</h1>
<p>In addition to HTML, CSS and Javascript helpers, there is also some more
<p>In addition to HTML, CSS and JavaScript helpers, there is also some more
general-purpose Shakespeare available. shakespeare-text provides a simple way
to create interpolated strings, much like people are accustomed to in scripting
languages like Ruby and Python. This package’s utility is definitely not
Expand Down
38 changes: 18 additions & 20 deletions public/book-1.6/widgets.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@


<p>One of the challenges in web development is that we have to coordinate three
different client-side technologies: HTML, CSS and Javascript. Worse still, we
different client-side technologies: HTML, CSS and JavaScript. Worse still, we
have to place these components in different locations on the page: CSS in a
style tag in the head, Javascript in a script tag before the closing body tag, and HTML in the
body. And never mind if you want to put your CSS and Javascript in separate
style tag in the head, JavaScript in a script tag before the closing body tag, and HTML in the
body. And never mind if you want to put your CSS and JavaScript in separate
files!</p>
<p>In practice, this works out fairly nicely when building a single page, because
we can separate our structure (HTML), style (CSS) and logic (Javascript). But
we can separate our structure (HTML), style (CSS) and logic (JavaScript). But
when we want to build modular pieces of code that can be easily composed, it
can be a headache to coordinate all three pieces separately. Widgets are
Yesod’s solution to the problem. They also help with the issue of including
Expand Down Expand Up @@ -126,7 +126,7 @@ <h1>What’s in a Widget?</h1>
</li>
<li>
<p>
Javascript code
JavaScript code
</p>
</li>
<li>
Expand Down Expand Up @@ -162,7 +162,7 @@ <h1>Constructing Widgets</h1>
style code appear in a separate file. The scaffolded site provides this for you
automatically.</p></aside>
<p>But what if you want to add some <code>&lt;meta&gt;</code> tags, which need to appear in
the head? Or if you want some Javascript to appear in the body instead of the
the head? Or if you want some JavaScript to appear in the body instead of the
head? For these purposes, Yesod provides two additional type classes:
<code>ToWidgetHead</code> and <code>ToWidgetBody</code>. These work exactly as they seem they should. One example use case for this is to have fine-grained control of where your <code>&lt;script&gt;</code> tags end up getting inserted.</p>
<pre language="haskell" linenumbering="unnumbered"><code class="haskell active web">{-# LANGUAGE OverloadedStrings #-}
Expand Down Expand Up @@ -247,7 +247,7 @@ <h1>Constructing Widgets</h1>
<section id="widgets_combining_widgets">
<h1>Combining Widgets</h1>
<p>The whole idea of widgets is to increase composability. You can take these
individual pieces of HTML, CSS and Javascript, combine them together into
individual pieces of HTML, CSS and JavaScript, combine them together into
something more complicated, and then combine these larger entities into
complete pages. This all works naturally through the <code>Monad</code> instance of
<code>Widget</code>, meaning you can use do-notation to compose pieces together.</p>
Expand Down Expand Up @@ -333,20 +333,18 @@ <h1>Types</h1>
answer is that each widget is a value of type <code>Widget</code>. But if you look through
the Yesod libraries, you’ll find no definition of the <code>Widget</code> type. What
gives?</p>
<p>Yesod defines a very similar type: <code>data WidgetT site m a</code>. This data type is a
<em role="strong">monad transformer</em>. The last two arguments are the underlying monad and the
monadic value, respectively. The site parameter is the specific foundation
type for your individual application. Since this type varies for each and every
site, it’s impossible for the libraries to define a single <code>Widget</code> datatype
which would work for every application.</p>
<p>Yesod defines a very similar type: <code>data WidgetFor site a</code>. This data
type is a <em role="strong">monad transformer</em>. The last argument <code>a</code> is the monadic
value. The site parameter is the specific foundation type for your
individual application. Since this type varies for each and every
site, it’s impossible for the libraries to define a single <code>Widget</code>
datatype which would work for every application.</p>
<p>Instead, the <code>mkYesod</code> Template Haskell function generates this type synonym
for you. Assuming your foundation data type is called <code>MyApp</code>, your <code>Widget</code>
synonym is defined as:</p>
<pre language="haskell" linenumbering="unnumbered"><code class="haskell">type Widget = WidgetT MyApp IO ()</code></pre>
<pre language="haskell" linenumbering="unnumbered"><code class="haskell">type Widget = WidgetFor MyApp ()</code></pre>
<p>We set the monadic value to be <code>()</code>, since a widget’s value will ultimately be
thrown away. <code>IO</code> is the standard base monad, and will be used in almost all
cases. The only exception is when writing a <em role="strong">subsite</em>. Subsites are a more
advanced topic, and will be covered later in their own chapter.</p>
thrown away.</p>
<p>Once we know about our <code>Widget</code> type synonym, it’s easy to add signatures to
our previous code samples:</p>
<pre language="haskell" linenumbering="unnumbered"><code class="haskell">footer :: Widget
Expand All @@ -371,15 +369,15 @@ <h1>Types</h1>
^{footer}
|]</code></pre>
<p>When we start digging into handler functions some more, we’ll encounter a
similar situation with the <code>HandlerT</code> and <code>Handler</code> types.</p>
similar situation with the <code>HandlerFor</code> and <code>Handler</code> types.</p>
</section>
</section>
<section id="widgets_using_widgets">
<h1>Using Widgets</h1>
<p>It’s all well and good that we have these beautiful Widget datatypes, but how
exactly do we turn them into something the user can interact with? The most
commonly used function is <code>defaultLayout</code>, which essentially has the type
signature <code>WidgetHandler Html</code>.</p>
signature <code>WidgetForHandlerFor Html</code>.</p>
<p><code>defaultLayout</code> is actually a typeclass method, which can be overridden for
each application. This is how Yesod apps are themed. So we’re still left with
the question: when we’re inside <code>defaultLayout</code>, how do we unwrap a <code>Widget</code>?
Expand Down Expand Up @@ -525,7 +523,7 @@ <h1>Using handler functions</h1>
<section id="widgets_summary">
<h1>Summary</h1>
<p>The basic building block of each page is a widget. Individual snippets of HTML,
CSS, and Javascript can be turned into widgets via the polymorphic <code>toWidget</code>
CSS, and JavaScript can be turned into widgets via the polymorphic <code>toWidget</code>
function. Using do-notation, you can combine these individual widgets into
larger widgets, eventually containing all the content of your page.</p>
<p>Unwrapping these widgets is usually performed within the defaultLayout
Expand Down
8 changes: 4 additions & 4 deletions public/book/basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>Routing</h1>
&quot;GET&quot; -&gt; getHomeR
_ -&gt; badMethod

type Handler = HandlerT HelloWorld IO</code></pre>
type Handler = HandlerFor HelloWorld</code></pre>
<aside class="note"><p>In addition to using <code>-ddump-splices</code>, it can often be useful to generate
Haddock documentation for your application to see which functions and data
types were generated for you.</p></aside>
Expand Down Expand Up @@ -154,10 +154,10 @@ <h1>Handler function</h1>
<code>whamlet</code> is another quasi-quoter. In this case, it converts Hamlet syntax into
a Widget. Hamlet is the default HTML templating engine in Yesod. Together with
its siblings Cassius, Lucius and Julius, you can create HTML, CSS and
Javascript in a fully type-safe and compile-time-checked manner. We’ll see much
JavaScript in a fully type-safe and compile-time-checked manner. We’ll see much
more about this in the Shakespeare chapter.</p>
<p>Widgets are another cornerstone of Yesod. They allow you to create modular
components of a site consisting of HTML, CSS and Javascript and reuse them
components of a site consisting of HTML, CSS and JavaScript and reuse them
throughout your site. We’ll get into more detail on them in the widgets
chapter.</p>
</section>
Expand Down Expand Up @@ -204,7 +204,7 @@ <h1>Running</h1>
<p>Once again we mention <code>HelloWorld</code> in our main function. Our foundation
contains all the information we need to route and respond to requests in our
application; now we just need to convert it into something that can run. A
useful function for this in Yesod is <code>warp</code>, which runs the Warp webserver with
useful function for this in Yesod is <code>warp</code>, which runs the Warp web server with
a number of default settings enabled on the specified port (here, it’s 3000).</p>
<p>One of the features of Yesod is that you aren’t tied down to a single
deployment strategy. Yesod is built on top of the Web Application Interface
Expand Down
6 changes: 3 additions & 3 deletions public/book/haskell.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</li>
</ul>
<p>Additionally, there are a number of great articles on
<a href="https://www.fpcomplete.com/school">School of Haskell</a>.</p>
<a href="https://tech.fpcomplete.com/haskell/learn/">FP Complete’s Haskell’s hub</a>.</p>
<p>In order to use Yesod, you’re going to have to know at least the basics of
Haskell. Additionally, Yesod uses some features of Haskell that aren’t covered
in most introductory texts. While this book assumes the reader has a basic
Expand Down Expand Up @@ -150,7 +150,7 @@ <h1>Language Pragmas</h1>
</li>
</ul>
<p>I personally never use the GHC command line argument approach. It’s a personal
preference, but I like to have my settings clearly stated in a file. In general
preference, but I like to have my settings clearly stated in a file. In general,
it’s recommended to avoid putting extensions in your <code>cabal</code> file; however,
this rule mostly applies when writing publicly available libraries. When you’re
writing an application that you and your team will be working on, having all of
Expand Down Expand Up @@ -281,7 +281,7 @@ <h1>Template Haskell</h1>
<p>A nice trick is that TH code is allowed to perform arbitrary <code>IO</code> actions, and
therefore we can place some input in external files and have it parsed at
compile time. One example usage is to have compile-time checked HTML, CSS, and
Javascript templates.</p>
JavaScript templates.</p>
<p>If your Template Haskell code is being used to generate declarations, and is
being placed at the top level of our file, we can leave off the dollar sign and
parentheses. In other words:</p>
Expand Down
2 changes: 1 addition & 1 deletion public/book/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
process a more pleasant one. As a community, we have continually pushed new
techniques to try and solve some of the lingering difficulties of security
threats, the stateless nature of HTTP, the multiple languages (HTML, CSS,
Javascript) necessary to create a powerful web application, and more.</p>
JavaScript) necessary to create a powerful web application, and more.</p>
<p>Yesod attempts to ease the web development process by playing to the strengths
of the Haskell programming language. Haskell’s strong compile-time guarantees
of correctness not only encompass types; referential transparency ensures that
Expand Down
Loading

0 comments on commit 18cf52f

Please sign in to comment.