Skip to content

Commit c1fa241

Browse files
committed
re-generate html, concatenate sed commands, remove trailing whitespace
1 parent 646c3d1 commit c1fa241

File tree

7 files changed

+39
-30
lines changed

7 files changed

+39
-30
lines changed

markdown/generate.sh

100644100755
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ cp source_md/chapters_head.md $chapterfile
1010
for i in ${!filename[@]}
1111
do
1212
sourcemd=source_md/${filename[$i]}.md
13-
14-
title[$i]=$(sed -n '/^# /s/# //p;' $sourcemd | sed 's/{.*//' | sed 's/ *$//g')
13+
14+
title[$i]=$(sed -n '/^# /s/# //p;' $sourcemd | sed 's/{.*//; s/ *$//g')
1515

1616
chnum=$(($i + 1))
1717
if [[ $chnum -ge 10 ]];
@@ -21,11 +21,11 @@ do
2121
sp=" "
2222
fi
2323

24-
sed -n '/^#\{1,2\} /p' $sourcemd \
25-
| sed "s/^# *\(.*[^ ]\) *{.*/$chnum.$sp[\1](${filename[$i]}.html)/" \
26-
| sed "s/^# *\(.*[^ ]\) */$chnum.$sp[\1](${filename[$i]}.html)/" \
27-
| sed "s/^## *\(.*[^ ]\) *{ *#\(.*\)}/ * [\1](${filename[$i]}.html\#\2)/" \
28-
>>$chapterfile
24+
grep '^#\{1,2\} ' $sourcemd \
25+
| sed "s/^# *\(.*[^ ]\) *{.*/$chnum.$sp[\1](${filename[$i]}.html)/;
26+
s/^# *\(.*[^ ]\) */$chnum.$sp[\1](${filename[$i]}.html)/;
27+
s/^## *\(.*[^ ]\) *{ *#\(.*\)}/ * [\1](${filename[$i]}.html\#\2)/" \
28+
>> $chapterfile
2929
done
3030

3131
for i in ${!filename[@]}
@@ -48,13 +48,13 @@ do
4848
next_title="${title[$next]}"
4949
next_filename=${filename[$next]}
5050
fi
51-
51+
5252
pandoc -d config/pandoc-defaults.yml --template=config/template.html \
5353
-V footdiv=true -V title="${title[$i]}" \
5454
--metadata title="${title[$i]}$titlesuffix" \
5555
-V prev_title="$prev_title" -V prev_filename=$prev_filename \
5656
-V next_title="$next_title" -V next_filename=$next_filename \
57-
-o generated_html/${filename[$i]}.html source_md/${filename[$i]}.md
57+
-o generated_html/${filename[$i]}.html source_md/${filename[$i]}.md
5858
done
5959

6060
cat source_md/chapters_foot.md >>$chapterfile

markdown/generated_html/functors-applicative-functors-and-monoids.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ <h2 id="functors-redux">Functors redux</h2>
412412
fmap f (Just x) = Just (f x)
413413
fmap f Nothing = Nothing</code></pre>
414414
<p>We imagine that <code>id</code> plays the role of the <code>f</code>
415-
parameter in the implementation. We see that if wee <code>fmap id</code>
415+
parameter in the implementation. We see that if we <code>fmap id</code>
416416
over <code>Just x</code>, the result will be <code>Just (id x)</code>,
417417
and because <code>id</code> just returns its parameter, we can deduce
418418
that <code>Just (id x)</code> equals <code>Just x</code>. So now we know

markdown/generated_html/higher-order-functions.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,10 @@ <h2 id="curried-functions">Curried functions</h2>
155155
instead of binding it to a name with a <em>let</em> or passing it to
156156
another function?</p>
157157
<pre class="haskell:hs"><code>ghci&gt; multThree 3 4
158-
&lt;interactive&gt;:1:0:
159-
No instance for (Show (t -&gt; t))
160-
arising from a use of `print&#39; at &lt;interactive&gt;:1:0-12
161-
Possible fix: add an instance declaration for (Show (t -&gt; t))
162-
In the expression: print it
163-
In a &#39;do&#39; expression: print it</code></pre>
158+
&lt;interactive&gt;:1:1: error: [GHC-39999]
159+
• No instance for ‘Show (a0 -&gt; a0)’ arising from a use of ‘print’
160+
(maybe you haven&#39;t applied a function to enough arguments?)
161+
• In a stmt of an interactive GHCi command: print it</code></pre>
164162
<p>GHCI is telling us that the expression produced a function of type
165163
<code>a -&gt; a</code> but it doesn’t know how to print it to the
166164
screen. Functions aren’t instances of the <code>Show</code> typeclass,

markdown/generated_html/introduction.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ <h2 id="about-this-tutorial">About this tutorial</h2>
5656
Haskell.</p>
5757
<p>The channel #haskell on the Libera.Chat network is a great place to
5858
ask questions if you’re feeling stuck. People there are extremely nice,
59-
patient and understanding to newbies.</p>
59+
patient and understanding to newbies. If IRC it not your cup of tea, <a
60+
href="https://discourse.haskell.org">https://discourse.haskell.org</a>
61+
is a popular community forum with a section for learners.</p>
6062
<p>I failed to learn Haskell approximately 2 times before finally
6163
grasping it because it all just seemed too weird to me and I didn’t get
6264
it. But then once it just “clicked” and after getting over that initial

markdown/generated_html/making-our-own-types-and-typeclasses.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,8 +1012,8 @@ <h2 id="recursive-data-structures">Recursive data structures</h2>
10121012
ghci&gt; let b = 6 :-: 7 :-: Empty
10131013
ghci&gt; a .++ b
10141014
(:-:) 3 ((:-:) 4 ((:-:) 5 ((:-:) 6 ((:-:) 7 Empty))))</code></pre>
1015-
<p>Nice. Is nice. If we wanted, we could implement all of the functions
1016-
that operate on lists on our own list type.</p>
1015+
<p>Nice. If we wanted, we could implement all of the functions that
1016+
operate on lists on our own list type.</p>
10171017
<p>Notice how we pattern matched on <code>(x :-: xs)</code>. That works
10181018
because pattern matching is actually about matching constructors. We can
10191019
match on <code>:-:</code> because it is a constructor for our own list

markdown/generated_html/starting-out.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ <h2 id="ready-set-go">Ready, set, go!</h2>
9696
True</code></pre>
9797
<p>What about doing <code>5 + "llama"</code> or <code>5 == True</code>?
9898
Well, if we try the first snippet, we get a big scary error message!</p>
99-
<pre class="haskell: ghci"><code>• No instance for (Num String) arising from a use of ‘+’
100-
• In the expression: 5 + &quot;llama&quot;
99+
<pre class="haskell: ghci"><code>&lt;interactive&gt;:1:1: error: [GHC-39999]
100+
• No instance for ‘Num String’ arising from the literal ‘5’
101+
• In the first argument of ‘(+)’, namely ‘5’
102+
In the expression: 5 + &quot;llama&quot;
101103
In an equation for ‘it’: it = 5 + &quot;llama&quot;</code></pre>
102104
<p>Yikes! What GHCI is telling us here is that <code>"llama"</code> is
103105
not a number and so it doesn’t know how to add it to 5. Even if it
@@ -113,6 +115,13 @@ <h2 id="ready-set-go">Ready, set, go!</h2>
113115
sneaky and can act like an integer or a floating-point number.
114116
<code>4.0</code> can’t act like an integer, so <code>5</code> is the one
115117
that has to adapt.</p>
118+
<div class="hintbox">
119+
<p><strong>Note:</strong> GHC errors are all assigned unique identifiers
120+
such as <code>GHC-39999</code> above. Whenever you are stuck with a
121+
stubborn error, you can look it up at <a
122+
href="https://errors.haskell.org/">https://errors.haskell.org/</a> to
123+
learn typical causes and solutions.</p>
124+
</div>
116125
<p>You may not have known it but we’ve been using functions now all
117126
along. For instance, <code>*</code> is a function that takes two numbers
118127
and multiplies them. As you’ve seen, we call it by sandwiching it
@@ -664,8 +673,9 @@ <h2 id="tuples">Tuples</h2>
664673
brackets, we use parentheses: <code>[(1,2),(8,11),(4,5)]</code>. What if
665674
we tried to make a shape like <code>[(1,2),(8,11,5),(4,5)]</code>? Well,
666675
we’d get this error:</p>
667-
<pre class="haskell: ghci"><code>• Couldn&#39;t match expected type ‘(a, b)’
668-
with actual type ‘(a0, b0, c0)’
676+
<pre class="haskell: ghci"><code>&lt;interactive&gt;:1:8: error: [GHC-83865]
677+
• Couldn&#39;t match expected type: (a, b)
678+
with actual type: (a0, b0, c0)
669679
• In the expression: (8, 11, 5)
670680
In the expression: [(1, 2), (8, 11, 5), (4, 5)]
671681
In an equation for ‘it’: it = [(1, 2), (8, 11, 5), (4, 5)]

markdown/generated_html/types-and-typeclasses.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,12 @@ <h2 id="typeclasses-101">Typeclasses 101</h2>
402402
floating point types to work together nicely. For instance, the
403403
<code>length</code> function has a type declaration of
404404
<code>length :: [a] -&gt; Int</code> instead of having a more general
405-
type of <code>(Num b) =&gt; length :: [a] -&gt; b</code>. I think that’s
406-
there for historical reasons or something, although in my opinion, it’s
407-
pretty stupid. Anyway, if we try to get a length of a list and then add
408-
it to <code>3.2</code>, we’ll get an error because we tried to add
409-
together an <code>Int</code> and a floating point number. So to get
410-
around this, we do <code>fromIntegral (length [1,2,3,4]) + 3.2</code>
411-
and it all works out.</p>
405+
type of <code>(Num b) =&gt; length :: [a] -&gt; b</code>. If we try to
406+
get a length of a list and then add it to <code>3.2</code>, we’ll get an
407+
error because we tried to add together an <code>Int</code> and a
408+
floating point number. So to get around this, we do
409+
<code>fromIntegral (length [1,2,3,4]) + 3.2</code> and it all works
410+
out.</p>
412411
<p>Notice that <code>fromIntegral</code> has several class constraints
413412
in its type signature. That’s completely valid and as you can see, the
414413
class constraints are separated by commas inside the parentheses.</p>

0 commit comments

Comments
 (0)