Skip to content

Commit 46c053b

Browse files
authored
* Fix typos * fixup! Fix typos
1 parent 023c463 commit 46c053b

15 files changed

+116
-116
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Discuss the ideas with the community.
3535
* Haskell Discourse - https://discourse.haskell.org/t/learn-you-a-haskell-a-community-version/4056
3636

3737
## Licence
38-
This domain and repository is in no way affiliated with Miran Lipovača (the original author) and is being extended and modified with his permision as per the licence the original work was released under ([Creative Commons Attribution-Noncommercial-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-nc-sa/3.0/)) as well as his literal statement encouraging modifiations to be made ([FAQ](http://learnyouahaskell.com/faq)).
38+
This domain and repository is in no way affiliated with Miran Lipovača (the original author) and is being extended and modified with his permision as per the licence the original work was released under ([Creative Commons Attribution-Noncommercial-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-nc-sa/3.0/)) as well as his literal statement encouraging modifications to be made ([FAQ](http://learnyouahaskell.com/faq)).
3939

4040
##
4141
This work is licensed under a [Creative Commons Attribution-Noncommercial-ShareAlike 3.0 Unported License](http://creativecommons.org/licenses/by-nc-sa/3.0/).

docs/a-fistful-of-monads.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ <h2>The Monad type class</h2>
400400
there be a class constraint in there along the lines of <span
401401
class="fixed">class (Applicative m) = &gt; Monad m where</span> so that a type
402402
has to be an applicative functor first before it can be made a monad? Well,
403-
there should, but when Haskell was made, it hadn't occured to people that
403+
there should, but when Haskell was made, it hadn't occurred to people that
404404
applicative functors are a good fit for Haskell so they weren't in there. But
405405
rest assured, every monad is an applicative functor, even if the <span
406406
class="fixed">Monad</span> class declaration doesn't say so.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ <h2>Writer? I hardly know her!</h2>
100100
<p>
101101
Now, what if instead of just giving us a <span class="fixed">True</span> or
102102
<span class="fixed">False</span> value, we want it to also return a log string
103-
that says what it did? Well, we just make that string and return it along side
103+
that says what it did? Well, we just make that string and return it alongside
104104
our <span class="fixed">Bool</span>:
105105
</p>
106106

@@ -566,7 +566,7 @@ <h3>Adding logging to programs</h3>
566566
greatest common divisor of 8 and 3 is, we just follow the algorithm outlined.
567567
Because 3 isn't 0, we have to find the greatest common divisor of 3 and 2
568568
(if we divide 8 by 3, the remainder is 2). Next, we find the greatest
569-
common divisor of 3 and 2. 2 still isn't 0, so now we have have 2 and 1. The
569+
common divisor of 3 and 2. 2 still isn't 0, so now we have 2 and 1. The
570570
second number isn't 0, so we run the algorithm again for 1 and 0, as
571571
dividing 2 by 1 gives us a remainder of 0. And finally, because the second number
572572
is now 0, the final result is 1. Let's see if our code agrees:
@@ -1231,7 +1231,7 @@ <h3>Stacks and stones</h3>
12311231
of another and you can either push stuff on top of that stack or you can take stuff
12321232
off the top of the stack. When you're putting an item on top of the stack we say
12331233
that you're pushing it to the stack and when you're taking stuff off the
1234-
top we say that you're popping it. If you want to something that's at the bottom
1234+
top we say that you're popping it. If you want something that's at the bottom
12351235
of the stack, you have to pop everything that's above it.
12361236
</p>
12371237

@@ -1628,7 +1628,7 @@ <h3>Randomness and the state monad</h3>
16281628
</pre>
16291629

16301630
<p>
1631-
<span class="fixed">threeCoins</span> is now a stateful computations and after
1631+
<span class="fixed">threeCoins</span> is now a stateful computation and after
16321632
taking an initial random generator, it passes it to the first <span
16331633
class="fixed">randomSt</span>, which produces a number and a new generator,
16341634
which gets passed to the next one and so on. We use <span class="fixed">return
@@ -2857,7 +2857,7 @@ <h2>Making monads</h2>
28572857

28582858
<p>
28592859
We took lists and we added some extra context to them, so this represents values
2860-
withs contexts too. Before we go any further, let's wrap this into a
2860+
with contexts too. Before we go any further, let's wrap this into a
28612861
<span class="fixed">newtype</span> because something tells me we'll be making
28622862
some instances.
28632863
</p>

docs/functionally-solving-problems.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</ul>
3333
</div>
3434
<h1>Functionally Solving Problems</h1>
35-
<p>In this chapter, we'll take a look at a few interesting problems and how to think functionally to solve them as elegantly as possible. We probably won't be introducing any new concepts, we'll just be flexing our newly acquired Haskell muscles and practicing our coding skills. Each section will present a different problem. First we'll describe the problem, then we'll try and find out what the best (or least worst) way of solving it is.</p>
35+
<p>In this chapter, we'll take a look at a few interesting problems and how to think functionally to solve them as elegantly as possible. We probably won't be introducing any new concepts, we'll just be flexing our newly acquired Haskell muscles and practicing our coding skills. Each section will present a different problem. First we'll describe the problem, then we'll try and find out what the best (or least bad) way of solving it is.</p>
3636
<a name="reverse-polish-notation-calculator"></a><h2>Reverse Polish notation calculator</h2>
3737
<p>Usually when we write mathematical expressions in school, we write them in an infix manner. For instance, we write <span class="fixed">10 - (4 + 3) * 2</span>. <span class="fixed">+</span>, <span class="fixed">*</span> and <span class="fixed">-</span> are infix operators, just like the infix functions we met in Haskell (<span class="fixed">+</span>, <span class="fixed">`elem`</span>, etc.). This makes it handy because we, as humans, can parse it easily in our minds by looking at such an expression. The downside to it is that we have to use parentheses to denote precedence.</p>
3838
<p><a href="https://en.wikipedia.org/wiki/Reverse_Polish_notation">Reverse Polish notation</a> is another way of writing down mathematical expressions. Initially it looks a bit weird, but it's actually pretty easy to understand and use because there's no need for parentheses and it's very easy to punch into a calculator. While most modern calculators use infix notation, some people still swear by RPN calculators. This is what the previous infix expression looks like in RPN: <span class="fixed">10 4 3 + 2 * -</span>. How do we calculate what the result of that is? Well, think of a stack. You go over the expression from left to right. Every time a number is encountered, push it on to the stack. When we encounter an operator, take the two numbers that are on top of the stack (we also say that we <i>pop</i> them), use the operator and those two and then push the resulting number back onto the stack. When you reach the end of the expression, you should be left with a single number if the expression was well-formed and that number represents the result.</p>
@@ -92,7 +92,7 @@ <h1>Functionally Solving Problems</h1>
9292
ghci&gt; solveRPN "90 3 -"
9393
87
9494
</pre>
95-
<p>Cool, it works! One nice thing about this function is that it can be easily modified to support various other operators. They don't even have to be binary operators. For instance, we can make an operator <span class="fixed">"log"</span> that just pops one number off the stack and pushes back its logarithm. We can also make a ternary operators that pop three numbers off the stack and push back a result or operators like <span class="fixed">"sum"</span> which pop off all the numbers and push back their sum. </p>
95+
<p>Cool, it works! One nice thing about this function is that it can be easily modified to support various other operators. They don't even have to be binary operators. For instance, we can make an operator <span class="fixed">"log"</span> that just pops one number off the stack and pushes back its logarithm. We can also make ternary operators that pop three numbers off the stack and push back a result or operators like <span class="fixed">"sum"</span> which pop off all the numbers and push back their sum. </p>
9696
<p>Let's modify our function to take a few more operators. For simplicity's sake, we'll change its type declaration so that it returns a number of type <span class="fixed">Float</span>.</p>
9797
<pre name="code" class="haskell:hs">
9898
import Data.List
@@ -125,7 +125,7 @@ <h1>Functionally Solving Problems</h1>
125125
6.575903
126126
</pre>
127127
<p>I think that making a function that can calculate arbitrary floating point RPN expressions and has the option to be easily extended in 10 lines is pretty awesome.</p>
128-
<p>One thing to note about this function is that it's not really fault tolerant. When given input that doesn't make sense, it will just crash everything. We'll make a fault tolerant version of this with a type declaration of <span class="fixed">solveRPN :: String -&gt; Maybe Float</span> once we get to know monads (they're not scary, trust me!). We could make one right now, but it would be a bit tedious because it would involve a lot of checking for <span class="fixed">Nothing</span> on every step. If you're feeling up to the challenge though, you can go ahead and try it! Hint: you can use <span class="fixed">reads</span> to see if a read was successful or not. </p>
128+
<p>One thing to note about this function is that it's not really fault-tolerant. When given input that doesn't make sense, it will just crash everything. We'll make a fault-tolerant version of this with a type declaration of <span class="fixed">solveRPN :: String -&gt; Maybe Float</span> once we get to know monads (they're not scary, trust me!). We could make one right now, but it would be a bit tedious because it would involve a lot of checking for <span class="fixed">Nothing</span> on every step. If you're feeling up to the challenge though, you can go ahead and try it! Hint: you can use <span class="fixed">reads</span> to see if a read was successful or not. </p>
129129
<a name="heathrow-to-london"></a><h2>Heathrow to London</h2>
130130
<p>Our next problem is this: your plane has just landed in England and you rent a car. You have a meeting really soon and you have to get from Heathrow Airport to London as fast as you can (but safely!).</p>
131131
<p>There are two main roads going from Heathrow to London and there's a number of regional roads crossing them. It takes you a fixed amount of time to travel from one crossroads to another. It's up to you to find the optimal path to take so that you get to London as fast as you can! You start on the left side and can either cross to the other main road or go forward.</p>

0 commit comments

Comments
 (0)