Skip to content

Commit 2f45203

Browse files
author
Gregory Cox
committed
Fix unmatched paragraph tags
1 parent 9af7c4b commit 2f45203

9 files changed

+23
-19
lines changed

docs/chapters.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ <h1>Learn You a Haskell for Great Good!</h1>
164164
</ul>
165165
</li>
166166
</ol>
167+
</p>
167168
<p>
168169
This work is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="nofollow">Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License</a> because I couldn’t find a license with an even longer name.
169170
</p>

docs/for-a-few-monads-more.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ <h1>For a Few Monads More</h1>
4848
saw how it lets us easily introduce non-determinism into our programs. We’ve also
4949
learned how to work in the <span class="fixed">IO</span> monad, even before we
5050
knew what a monad was!
51+
</p>
5152

5253
<p>
5354
In this chapter, we’re going to learn about a few other monads. We’ll see how
@@ -926,6 +927,7 @@ <h3>Comparing Performance</h3>
926927
Anyway, if you load this function in GHCi and apply it to a big number,
927928
like <span class="fixed">500000</span>, you’ll see that it quickly starts counting from
928929
<span class="fixed">0</span> onwards:
930+
</p>
929931

930932
<pre name="code" class="haskell:hs">
931933
ghci&gt; mapM_ putStrLn . fromDiffList . snd . runWriter $ finalCountDown 500000

docs/functionally-solving-problems.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ <h1>Functionally Solving Problems</h1>
182182
data Section = Section { getA :: Int, getB :: Int, getC :: Int } deriving (Show)
183183
type RoadSystem = [Section]
184184
</pre>
185-
<p>This is pretty much perfect! It’s as simple as it goes and I have a feeling it’ll work perfectly for implementing our solution. <span class="fixed">Section</span> is a simple algebraic data type that holds three integers for the lengths of its three road parts. We introduce a type synonym as well, saying that <span class="fixed">RoadSystem</span> is a list of sections.
185+
<p>This is pretty much perfect! It’s as simple as it goes and I have a feeling it’ll work perfectly for implementing our solution. <span class="fixed">Section</span> is a simple algebraic data type that holds three integers for the lengths of its three road parts. We introduce a type synonym as well, saying that <span class="fixed">RoadSystem</span> is a list of sections.</p>
186186
<div class="hintbox">We could also use a triple of <span class="fixed">(Int, Int, Int)</span> to represent a road section. Using tuples instead of making your own algebraic data types is good for some small localized stuff, but it’s usually better to make a new type for things like this. It gives the type system more information about what’s what. We can use <span class="fixed">(Int, Int, Int)</span> to represent a road section or a vector in 3D space and we can operate on those two, but that allows us to mix them up. If we use <span class="fixed">Section</span> and <span class="fixed">Vector</span> data types, then we can’t accidentally add a vector to a section of a road system.</div>
187187
<p>Our road system from Heathrow to London can now be represented like this:</p>
188188
<pre name="code" class="haskell:hs">

docs/functors-applicative-functors-and-monoids.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ <h1>Functors, Applicative Functors and Monoids</h1>
251251
<p>This simple three line class definition tells us a lot! Let’s start at the first line. It starts the definition of the <span class="fixed">Applicative</span> class and it also introduces a class constraint. It says that if we want to make a type constructor part of the <span class="fixed">Applicative</span> typeclass, it has to be in <span class="fixed">Functor</span> first. That’s why if we know that if a type constructor is part of the <span class="fixed">Applicative</span> typeclass, it’s also in <span class="fixed">Functor</span>, so we can use <span class="fixed">fmap</span> on it.</p>
252252
<p>The first method it defines is called <span class="fixed">pure</span>. Its type declaration is <span class="fixed">pure :: a -&gt; f a</span>. <span class="fixed">f</span> plays the role of our applicative functor instance here. Because Haskell has a very good type system and because everything a function can do is take some parameters and return some value, we can tell a lot from a type declaration and this is no exception. <span class="fixed">pure</span> should take a value of any type and return an applicative functor with that value inside it. When we say <i>inside it</i>, we’re using the box analogy again, even though we’ve seen that it doesn’t always stand up to scrutiny. But the <span class="fixed">a -&gt; f a</span> type declaration is still pretty descriptive. We take a value and we wrap it in an applicative functor that has that value as the result inside it.</p>
253253
<p>A better way of thinking about <span class="fixed">pure</span> would be to say that it takes a value and puts it in some sort of default (or pure) context—a minimal context that still yields that value.</p>
254-
<p>The <span class="fixed">&lt;*&gt;</span> function is really interesting. It has a type declaration of <span class="fixed">f (a -&gt; b) -&gt; f a -&gt; f b</span>. Does this remind you of anything? Of course, <span class="fixed">fmap :: (a -&gt; b) -&gt; f a -&gt; f b</span>. It’s a sort of a beefed up <span class="fixed">fmap</span>. Whereas <span class="fixed">fmap</span> takes a function and a functor and applies the function inside the functor, <span class="fixed">&lt;*&gt;</span> takes a functor that has a function in it and another functor and sort of extracts that function from the first functor and then maps it over the second one. When I say <i>extract</i>, I actually sort of mean <i>run</i> and then extract, maybe even <i>sequence</i>. We’ll see why soon.
254+
<p>The <span class="fixed">&lt;*&gt;</span> function is really interesting. It has a type declaration of <span class="fixed">f (a -&gt; b) -&gt; f a -&gt; f b</span>. Does this remind you of anything? Of course, <span class="fixed">fmap :: (a -&gt; b) -&gt; f a -&gt; f b</span>. It’s a sort of a beefed up <span class="fixed">fmap</span>. Whereas <span class="fixed">fmap</span> takes a function and a functor and applies the function inside the functor, <span class="fixed">&lt;*&gt;</span> takes a functor that has a function in it and another functor and sort of extracts that function from the first functor and then maps it over the second one. When I say <i>extract</i>, I actually sort of mean <i>run</i> and then extract, maybe even <i>sequence</i>. We’ll see why soon.</p>
255255
<p>Let’s take a look at the <span class="fixed">Applicative</span> instance implementation for <span class="fixed">Maybe</span>.</p>
256256
<pre name="code" class="haskell:hs">
257257
instance Applicative Maybe where
@@ -1074,6 +1074,7 @@ <h3><span class="fixed">type</span> vs. <span class="fixed">newtype</span> vs. <
10741074
<span class="fixed">Ord</span>, which is for things that can be put in an order
10751075
and then moved on to more interesting ones, like
10761076
<span class="fixed">Functor</span> and <span class="fixed">Applicative</span>.
1077+
</p>
10771078

10781079
<p>
10791080
When we make a type, we think about which behaviors it supports, i.e. what it can

0 commit comments

Comments
 (0)