Skip to content

Commit f591232

Browse files
committed
Fix typos found by codespell
1 parent 7c5423a commit f591232

11 files changed

+17
-17
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ <h1>Functors, Applicative Functors and Monoids</h1>
167167
fmap f (Just x) = Just (f x)
168168
fmap f Nothing = Nothing
169169
</pre>
170-
<p>We imagine that <span class="fixed">id</span> plays the role of the <span class="fixed">f</span> parameter in the implementation. We see that if wee <span class="fixed">fmap id</span> over <span class="fixed">Just x</span>, the result will be <span class="fixed">Just (id x)</span>, and because <span class="fixed">id</span> just returns its parameter, we can deduce that <span class="fixed">Just (id x)</span> equals <span class="fixed">Just x</span>. So now we know that if we map <span class="fixed">id</span> over a <span class="fixed">Maybe</span> value with a <span class="fixed">Just</span> value constructor, we get that same value back.</p>
170+
<p>We imagine that <span class="fixed">id</span> plays the role of the <span class="fixed">f</span> parameter in the implementation. We see that if we <span class="fixed">fmap id</span> over <span class="fixed">Just x</span>, the result will be <span class="fixed">Just (id x)</span>, and because <span class="fixed">id</span> just returns its parameter, we can deduce that <span class="fixed">Just (id x)</span> equals <span class="fixed">Just x</span>. So now we know that if we map <span class="fixed">id</span> over a <span class="fixed">Maybe</span> value with a <span class="fixed">Just</span> value constructor, we get that same value back.</p>
171171
<p>Seeing that mapping <span class="fixed">id</span> over a <span class="fixed">Nothing</span> value returns the same value is trivial. So from these two equations in the implementation for <span class="fixed">fmap</span>, we see that the law <span class="fixed">fmap id = id</span> holds.</p>
172172
<img src="assets/images/functors-applicative-functors-and-monoids/justice.png" alt="justice is blind, but so is my dog" class="left" width="345" height="428">
173173
<p><em>The second law says that composing two functions and then mapping the resulting function over a functor should be the same as first mapping one function over the functor and then mapping the other one.</em> Formally written, that means that <span class="label law">fmap (f . g) = fmap f . fmap g</span>. Or to write it in another way, for any functor <i>F</i>, the following should hold: <span class="label law">fmap (f . g) F = fmap f (fmap g F)</span>.</p>
@@ -512,7 +512,7 @@ <h1>Functors, Applicative Functors and Monoids</h1>
512512
True
513513
</pre>
514514
<p><span class="fixed">sequenceA [(&gt;4),(&lt;10),odd]</span> creates a function that will take a number and feed it to all of the predicates in <span class="fixed">[(&gt;4),(&lt;10),odd]</span> and return a list of booleans. It turns a list with the type <span class="fixed">(Num a) =&gt; [a -&gt; Bool]</span> into a function with the type <span class="fixed">(Num a) =&gt; a -&gt; [Bool]</span>. Pretty neat, huh?</p>
515-
<p>Because lists are homogenous, all the functions in the list have to be functions of the same type, of course. You can't have a list like <span class="fixed">[ord, (+3)]</span>, because <span class="fixed">ord</span> takes a character and returns a number, whereas <span class="fixed">(+3)</span> takes a number and returns a number.</p>
515+
<p>Because lists are homogeneous, all the functions in the list have to be functions of the same type, of course. You can't have a list like <span class="fixed">[ord, (+3)]</span>, because <span class="fixed">ord</span> takes a character and returns a number, whereas <span class="fixed">(+3)</span> takes a number and returns a number.</p>
516516
<p>When used with <span class="fixed">[]</span>, <span class="fixed">sequenceA</span> takes a list of lists and returns a list of lists. Hmm, interesting. It actually creates lists that have all possible combinations of their elements. For illustration, here's the above done with <span class="fixed">sequenceA</span> and then done with a list comprehension:</p>
517517
<pre name="code" class="haskell:hs">
518518
ghci&gt; sequenceA [[1,2,3],[4,5,6]]

docs/higher-order-functions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ <h1 style="margin-left:-3px">Higher order functions</h1>
325325
sum' = foldl (+) 0
326326
</pre>
327327
<p>The lambda function <span class="fixed">(\acc x -&gt; acc + x)</span> is the same as <span class="fixed">(+)</span>. We can omit the <span class="fixed">xs</span> as the parameter because calling <span class="fixed">foldl (+) 0</span> will return a function that takes a list. Generally, if you have a function like <span class="fixed">foo a = bar b a</span>, you can rewrite it as <span class="fixed">foo = bar b</span>, because of currying.</p>
328-
<p>Anyhoo, let's implement another function with a left fold before moving on to right folds. I'm sure you all know that <span class="fixed">elem</span> checks whether a value is part of a list so I won't go into that again (whoops, just did!). Let's implement it with a left fold. </p>
328+
<p>Anyhow, let's implement another function with a left fold before moving on to right folds. I'm sure you all know that <span class="fixed">elem</span> checks whether a value is part of a list so I won't go into that again (whoops, just did!). Let's implement it with a left fold. </p>
329329
<pre name="code" class="haskell:hs">
330330
elem' :: (Eq a) =&gt; a -&gt; [a] -&gt; Bool
331331
elem' y ys = foldl (\acc x -&gt; if x == y then True else acc) False ys

docs/input-and-output.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ <h1>Input and Output</h1>
11691169
</pre>
11701170
<img src="assets/images/input-and-output/police.png" width="241" height="328" alt="Stop right there, criminal scum! Nobody breaks the law on my watch! Now pay your fine or it's off to jail." class="left">
11711171
<p>Pure code can throw exceptions, but they can only be caught in the I/O part of our code (when we're inside a <i>do</i> block that goes into <span class="fixed">main</span>). That's because you don't know when (or if) anything will be evaluated in pure code, because it is lazy and doesn't have a well-defined order of execution, whereas I/O code does.</p>
1172-
<p>Earlier, we talked about how we should spend as little time as possible in the I/O part of our program. The logic of our program should reside mostly within our pure functions, because their results are dependant only on the parameters that the functions are called with. When dealing with pure functions, you only have to think about what a function returns, because it can't do anything else. This makes your life easier. Even though doing some logic in I/O is necessary (like opening files and the like), it should preferably be kept to a minimum. Pure functions are lazy by default, which means that we don't know when they will be evaluated and that it really shouldn't matter. However, once pure functions start throwing exceptions, it matters when they are evaluated. That's why we can only catch exceptions thrown from pure functions in the I/O part of our code. And that's bad, because we want to keep the I/O part as small as possible. However, if we don't catch them in the I/O part of our code, our program crashes. The solution? Don't mix exceptions and pure code. Take advantage of Haskell's powerful type system and use types like <span class="fixed">Either</span> and <span class="fixed">Maybe</span> to represent results that may have failed.</p>
1172+
<p>Earlier, we talked about how we should spend as little time as possible in the I/O part of our program. The logic of our program should reside mostly within our pure functions, because their results are dependent only on the parameters that the functions are called with. When dealing with pure functions, you only have to think about what a function returns, because it can't do anything else. This makes your life easier. Even though doing some logic in I/O is necessary (like opening files and the like), it should preferably be kept to a minimum. Pure functions are lazy by default, which means that we don't know when they will be evaluated and that it really shouldn't matter. However, once pure functions start throwing exceptions, it matters when they are evaluated. That's why we can only catch exceptions thrown from pure functions in the I/O part of our code. And that's bad, because we want to keep the I/O part as small as possible. However, if we don't catch them in the I/O part of our code, our program crashes. The solution? Don't mix exceptions and pure code. Take advantage of Haskell's powerful type system and use types like <span class="fixed">Either</span> and <span class="fixed">Maybe</span> to represent results that may have failed.</p>
11731173
<p>That's why we'll just be looking at how to use I/O exceptions for now. I/O exceptions are exceptions that are caused when something goes wrong while we are communicating with the outside world in an I/O action that's part of <span class="fixed">main</span>. For example, we can try opening a file and then it turns out that the file has been deleted or something. Take a look at this program that opens a file whose name is given to it as a command line argument and tells us how many lines the file has.</p>
11741174
<pre name="code" class="haskell:hs">
11751175
import System.Environment

docs/starting-out.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ <h1 style="margin-left:-3px">Starting Out</h1>
212212
Much like shopping lists in the real world, lists in Haskell are very useful. It's the most used data structure and it can be used in a multitude of different ways to model and solve a whole bunch of problems. Lists are SO awesome. In this section we'll look at the basics of lists, strings (which are lists) and list comprehensions.
213213
</p>
214214
<p>
215-
In Haskell, lists are a <em>homogenous</em> data structure. They store several elements of the same type. That means that we can have a list of integers or a list of characters but we can't have a list that has a few integers and then a few characters. And now, a list!
215+
In Haskell, lists are a <em>homogeneous</em> data structure. They store several elements of the same type. That means that we can have a list of integers or a list of characters but we can't have a list that has a few integers and then a few characters. And now, a list!
216216
</p>
217217
<pre name="code" class="haskell: ghci">
218218
ghci&gt; lostNumbers = [4,8,15,16,23,42]
@@ -479,7 +479,7 @@ <h1 style="margin-left:-3px">Starting Out</h1>
479479
<a name="tuples"></a><h2>Tuples</h2>
480480
<img src="assets/images/starting-out/tuple.png" alt="tuples" class="right" width="160" height="162">
481481
<p>In some ways, tuples are like lists &mdash; they are a way to store several values into a single value. However, there are a few fundamental differences. A list of numbers is a list of numbers. That's its type and it doesn't matter if it has only one number in it or an infinite amount of numbers. Tuples, however, are used when you know exactly how many values you want to combine and its type depends on how many components it has and the types of the components. They are denoted with parentheses and their components are separated by commas.</p>
482-
<p>Another key difference is that they don't have to be homogenous. Unlike a list, a tuple can contain a combination of several types.</p>
482+
<p>Another key difference is that they don't have to be homogeneous. Unlike a list, a tuple can contain a combination of several types.</p>
483483
<p>Think about how we'd represent a two-dimensional vector in Haskell. One way would be to use a list. That would kind of work. So what if we wanted to put a couple of vectors in a list to represent points of a shape on a two-dimensional plane? We could do something like <span class="fixed">[[1,2],[8,11],[4,5]]</span>. The problem with that method is that we could also do stuff like <span class="fixed">[[1,2],[8,11,5],[4,5]]</span>, which Haskell has no problem with since it's still a list of lists with numbers, but it kind of doesn't make sense. But a tuple of size two (also called a pair) is its own type, which means that a list can't have a couple of pairs in it and then a triple (a tuple of size three), so let's use that instead. Instead of surrounding the vectors with square brackets, we use parentheses: <span class="fixed">[(1,2),(8,11),(4,5)]</span>. What if we tried to make a shape like <span class="fixed">[(1,2),(8,11,5),(4,5)]</span>? Well, we'd get this error:</p>
484484
<pre name="code" class="haskell: ghci">
485485
• Couldn't match expected type ‘(a, b)’

markdown/source_md/functionally-solving-problems.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Also noticed that we added an extra class constraint of `Read a` to the function
138138
So this declaration means that the result can be of any type that's part of the `Num` and `Read` typeclasses (like `Int`, `Float`, etc.).
139139

140140
For the list of items `["2","3","+"]`, our function will start folding from the left.
141-
The intial stack will be `[]`.
141+
The initial stack will be `[]`.
142142
It will call the folding function with `[]` as the stack (accumulator) and `"2"` as the item.
143143
Because that item is not an operator, it will be `read` and the added to the beginning of `[]`.
144144
So the new stack is now `[2]` and the folding function will be called with `[2]` as the stack and `["3"]` as the item, producing a new stack of `[3,2]`.

markdown/source_md/functors-applicative-functors-and-monoids.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ Finally, `Just (3+) <*> Just 5` is carried out, which results in a `Just 8`.
586586

587587
Isn't this awesome?!
588588
Applicative functors and the applicative style of doing `pure f <*> x <*> y <*> ...` allow us to take a function that expects parameters that aren't necessarily wrapped in functors and use that function to operate on several values that are in functor contexts.
589-
The function can take as many parameters as we want, because it's always partially applied step by step between occurences of `<*>`.
589+
The function can take as many parameters as we want, because it's always partially applied step by step between occurrences of `<*>`.
590590

591591
This becomes even more handy and apparent if we consider the fact that `pure f <*> x` equals `fmap f x`.
592592
This is one of the applicative laws.
@@ -1047,7 +1047,7 @@ True
10471047
It turns a list with the type `(Num a) => [a -> Bool]` into a function with the type `(Num a) => a -> [Bool]`.
10481048
Pretty neat, huh?
10491049

1050-
Because lists are homogenous, all the functions in the list have to be functions of the same type, of course.
1050+
Because lists are homogeneous, all the functions in the list have to be functions of the same type, of course.
10511051
You can't have a list like `[ord, (+3)]`, because `ord` takes a character and returns a number, whereas `(+3)` takes a number and returns a number.
10521052

10531053
When used with `[]`, `sequenceA` takes a list of lists and returns a list of lists.
@@ -1578,7 +1578,7 @@ We were able to use the general type of `[a]` (as opposed to specifying `[Int]`
15781578

15791579
Because `mconcat` has a default implementation, we get it for free when we make something an instance of `Monoid`.
15801580
In the case of the list, `mconcat` turns out to be just `concat`.
1581-
It takes a list of lists and flattens it, because that's the equivalent of doing `++` between all the adjecent lists in a list.
1581+
It takes a list of lists and flattens it, because that's the equivalent of doing `++` between all the adjacent lists in a list.
15821582

15831583
The monoid laws do indeed hold for the list instance.
15841584
When we have several lists and we `mappend` (or `++`) them together, it doesn't matter which ones we do first, because they're just joined at the ends anyway.

markdown/source_md/higher-order-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ The lambda function `(\acc x -> acc + x)` is the same as `(+)`.
617617
We can omit the `xs` as the parameter because calling `foldl (+) 0` will return a function that takes a list.
618618
Generally, if you have a function like `foo a = bar b a`, you can rewrite it as `foo = bar b`, because of currying.
619619

620-
Anyhoo, let's implement another function with a left fold before moving on to right folds.
620+
Anyhow, let's implement another function with a left fold before moving on to right folds.
621621
I'm sure you all know that `elem` checks whether a value is part of a list so I won't go into that again (whoops, just did!).
622622
Let's implement it with a left fold.
623623

markdown/source_md/input-and-output.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ Pure code can throw exceptions, but they can only be caught in the I/O part of o
20712071
That's because you don't know when (or if) anything will be evaluated in pure code, because it is lazy and doesn't have a well-defined order of execution, whereas I/O code does.
20722072

20732073
Earlier, we talked about how we should spend as little time as possible in the I/O part of our program.
2074-
The logic of our program should reside mostly within our pure functions, because their results are dependant only on the parameters that the functions are called with.
2074+
The logic of our program should reside mostly within our pure functions, because their results are dependent only on the parameters that the functions are called with.
20752075
When dealing with pure functions, you only have to think about what a function returns, because it can't do anything else.
20762076
This makes your life easier.
20772077
Even though doing some logic in I/O is necessary (like opening files and the like), it should preferably be kept to a minimum.

markdown/source_md/modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ rectangleArea a b = a * b
13281328
Pretty standard geometry right here.
13291329
There are a few things to take note of though.
13301330
Because a cube is only a special case of a cuboid, we defined its area and volume by treating it as a cuboid whose sides are all of the same length.
1331-
We also defined a helper function called `rectangleArea`, which calculates a rectangle's area based on the lenghts of its sides.
1331+
We also defined a helper function called `rectangleArea`, which calculates a rectangle's area based on the lengths of its sides.
13321332
It's rather trivial because it's just multiplication.
13331333
Notice that we used it in our functions in the module (namely `cuboidArea` and `cuboidVolume`) but we didn't export it!
13341334
Because we want our module to just present functions for dealing with three-dimensional objects, we used `rectangleArea` but we didn't export it.

markdown/source_md/starting-out.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ It's the most used data structure and it can be used in a multitude of different
286286
Lists are SO awesome.
287287
In this section we'll look at the basics of lists, strings (which are lists) and list comprehensions.
288288

289-
In Haskell, lists are a **homogenous** data structure.
289+
In Haskell, lists are a **homogeneous** data structure.
290290
They store several elements of the same type.
291291
That means that we can have a list of integers or a list of characters but we can't have a list that has a few integers and then a few characters.
292292
And now, a list!
@@ -771,7 +771,7 @@ That's its type and it doesn't matter if it has only one number in it or an infi
771771
Tuples, however, are used when you know exactly how many values you want to combine and its type depends on how many components it has and the types of the components.
772772
They are denoted with parentheses and their components are separated by commas.
773773

774-
Another key difference is that they don't have to be homogenous.
774+
Another key difference is that they don't have to be homogeneous.
775775
Unlike a list, a tuple can contain a combination of several types.
776776

777777
Think about how we'd represent a two-dimensional vector in Haskell.
@@ -881,7 +881,7 @@ ghci> triangles = [ (a,b,c) | c <- [1..10], b <- [1..10], a <- [1..10] ]
881881
We're just drawing from three lists and our output function is combining them into a triple.
882882
If you evaluate that by typing out `triangles` in GHCI, you'll get a list of all possible triangles with sides under or equal to 10.
883883
Next, we'll add a condition that they all have to be right triangles.
884-
We'll also modify this function by taking into consideration that side b isn't larger than the hypothenuse and that side a isn't larger than side b.
884+
We'll also modify this function by taking into consideration that side b isn't larger than the hypotenuse and that side a isn't larger than side b.
885885

886886
```{.haskell: .ghci}
887887
ghci> rightTriangles = [ (a,b,c) | c <- [1..10], b <- [1..c], a <- [1..b], a^2 + b^2 == c^2]

0 commit comments

Comments
 (0)