Skip to content

Commit 1ca8330

Browse files
authored
"guys" -> "people" (#51)
* really smart "guys" -> "folk" * "guys" -> "folks" * "the boys" -> "my buddies" * Phonebook example 'girl' -> 'friend'
1 parent 26de418 commit 1ca8330

File tree

9 files changed

+132
-132
lines changed

9 files changed

+132
-132
lines changed

docs/introduction.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2>About this tutorial</h2>
6868
Haskell is <em>elegant and concise</em>. Because it uses a lot of high level concepts, Haskell programs are usually shorter than their imperative equivalents. And shorter programs are easier to maintain than longer ones and have less bugs.
6969
</p>
7070
<p>
71-
Haskell was made by some <em>really smart guys</em> (with PhDs). Work on Haskell began in 1987 when a committee of researchers got together to design a kick-ass language. In 2003 the Haskell Report was published, which defines a stable version of the language.
71+
Haskell was made by some <em>really smart folk</em> (with PhDs). Work on Haskell began in 1987 when a committee of researchers got together to design a kick-ass language. In 2003 the Haskell Report was published, which defines a stable version of the language.
7272
</p>
7373
<a name="what-you-need"></a><h2>What you need to dive in</h2>
7474
<p>

docs/making-our-own-types-and-typeclasses.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,12 @@ <h1>Making Our Own Types and Typeclasses</h1>
488488
<pre name="code" class="haskell:hs">
489489
phoneBook :: [(String,String)]
490490
phoneBook =
491-
[("betty","555-2938")
492-
,("bonnie","452-2928")
493-
,("patsy","493-2928")
494-
,("lucille","205-2928")
495-
,("wendy","939-8282")
496-
,("penny","853-2492")
491+
[("amelia","555-2938")
492+
,("freya","452-2928")
493+
,("isabella","493-2928")
494+
,("neil","205-2928")
495+
,("roald","939-8282")
496+
,("tenzing","853-2492")
497497
]</pre>
498498
<p>We see that the type of <span class="fixed">phoneBook</span> is <span class="fixed">[(String,String)]</span>. That tells us that it's an association list that maps from strings to strings, but not much else. Let's make a type synonym to convey some more information in the type declaration.</p>
499499
<pre name="code" class="haskell:hs">
@@ -517,7 +517,7 @@ <h1>Making Our Own Types and Typeclasses</h1>
517517
type AssocList k v = [(k,v)]
518518
</pre>
519519
<p>Now, a function that gets the value by a key in an association list can have a type of <span class="fixed">(Eq k) =&gt; k -&gt; AssocList k v -&gt; Maybe v</span>. <span class="fixed">AssocList</span> is a type constructor that takes two types and produces a concrete type, like <span class="fixed">AssocList Int String</span>, for instance.</p>
520-
<div class="hintbox"><em>Fonzie says:</em> Aaay! When I talk about <i>concrete types</i> I mean like fully applied types like <span class="fixed">Map Int String</span> or if we're dealin' with one of them polymorphic functions, <span class="fixed">[a]</span> or <span class="fixed">(Ord a) =&gt; Maybe a</span> and stuff. And like, sometimes me and the boys say that <span class="fixed">Maybe</span> is a type, but we don't mean that, cause every idiot knows <span class="fixed">Maybe</span> is a type constructor. When I apply an extra type to <span class="fixed">Maybe</span>, like <span class="fixed">Maybe String</span>, then I have a concrete type. You know, values can only have types that are concrete types! So in conclusion, live fast, love hard and don't let anybody else use your comb!</div>
520+
<div class="hintbox"><em>Fonzie says:</em> Aaay! When I talk about <i>concrete types</i> I mean like fully applied types like <span class="fixed">Map Int String</span> or if we're dealin' with one of them polymorphic functions, <span class="fixed">[a]</span> or <span class="fixed">(Ord a) =&gt; Maybe a</span> and stuff. And like, sometimes me and my buddies say that <span class="fixed">Maybe</span> is a type, but we don't mean that, cause every idiot knows <span class="fixed">Maybe</span> is a type constructor. When I apply an extra type to <span class="fixed">Maybe</span>, like <span class="fixed">Maybe String</span>, then I have a concrete type. You know, values can only have types that are concrete types! So in conclusion, live fast, love hard and don't let anybody else use your comb!</div>
521521
<p>Just like we can partially apply functions to get new functions, we can partially apply type parameters and get new type constructors from them. Just like we call a function with too few parameters to get back a new function, we can specify a type constructor with too few type parameters and get back a partially applied type constructor. If we wanted a type that represents a map (from <span class="fixed">Data.Map</span>) from integers to something, we could either do this:</p>
522522
<pre name="code" class="haskell:hs">
523523
type IntMap v = Map Int v

docs/modules.html

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ <h1>Modules</h1>
8383
</pre>
8484
<p><span class="label function">intercalate</span> takes a list and a list of lists. It then inserts that list in between all those lists and then flattens the result.</p>
8585
<pre name="code" class="haskell:ghci">
86-
ghci&gt; intercalate " " ["hey","there","guys"]
87-
"hey there guys"
86+
ghci&gt; intercalate " " ["hey","there","folks"]
87+
"hey there folks"
8888
ghci&gt; intercalate [0,0,0] [[1,2,3],[4,5,6],[7,8,9]]
8989
[1,2,3,0,0,0,4,5,6,0,0,0,7,8,9]
9090
</pre>
9191
<p><span class="label function">transpose</span> transposes a list of lists. If you look at a list of lists as a 2D matrix, the columns become the rows and vice versa.</p>
9292
<pre name="code" class="haskell:ghci">
9393
ghci&gt; transpose [[1,2,3],[4,5,6],[7,8,9]]
9494
[[1,4,7],[2,5,8],[3,6,9]]
95-
ghci&gt; transpose ["hey","there","guys"]
95+
ghci&gt; transpose ["hey","there","folks"]
9696
["htg","ehu","yey","rs","e"]
9797
</pre>
9898
<p>Say we have the polynomials <i>3x<sup>2</sup> + 5x + 9</i>, <i>10x<sup>3</sup> + 9</i> and <i>8x<sup>3</sup> + 5x<sup>2</sup> + x - 1</i> and we want to add them together. We can use the lists <span class="fixed">[0,3,5,9]</span>, <span class="fixed">[10,0,0,9]</span> and <span class="fixed">[8,5,1,-1]</span> to represent them in Haskell. Now, to add them, all we have to do is this:</p>
@@ -442,16 +442,16 @@ <h1>Modules</h1>
442442
<p>Kewl. In case you don't remember, <span class="fixed">all</span> takes a predicate and a list and returns <span class="fixed">True</span> only if that predicate holds for every element in the list.</p>
443443
<p>We can also use <span class="fixed">isSpace</span> to simulate the <span class="fixed">Data.List</span> function <span class="fixed">words</span>.
444444
<pre name="code" class="haskell:ghci">
445-
ghci&gt; words "hey guys its me"
446-
["hey","guys","its","me"]
447-
ghci&gt; groupBy ((==) `on` isSpace) "hey guys its me"
448-
["hey"," ","guys"," ","its"," ","me"]
445+
ghci&gt; words "hey folks its me"
446+
["hey","folks","its","me"]
447+
ghci&gt; groupBy ((==) `on` isSpace) "hey folks its me"
448+
["hey"," ","folks"," ","its"," ","me"]
449449
ghci&gt;
450450
</pre>
451451
<p>Hmmm, well, it kind of does what <span class="fixed">words</span> does but we're left with elements of only spaces. Hmm, whatever shall we do? I know, let's filter that sucker.</p>
452452
<pre name="code" class="haskell:ghci">
453-
ghci&gt; filter (not . any isSpace) . groupBy ((==) `on` isSpace) $ "hey guys its me"
454-
["hey","guys","its","me"]
453+
ghci&gt; filter (not . any isSpace) . groupBy ((==) `on` isSpace) $ "hey folks its me"
454+
["hey","folks","its","me"]
455455
</pre>
456456
<p>Ah.</p>
457457
<p>The <span class="fixed">Data.Char</span> also exports a datatype that's kind of like <span class="fixed">Ordering</span>. The <span class="fixed">Ordering</span> type can have a value of <span class="fixed">LT</span>, <span class="fixed">EQ</span> or <span class="fixed">GT</span>. It's a sort of enumeration. It describes a few possible results that can arise from comparing two elements. The <span class="fixed">GeneralCategory</span> type is also an enumeration. It presents us with a few possible categories that a character can fall into. The main function for getting the general category of a character is <span class="fixed">generalCategory</span>. It has a type of <span class="fixed">generalCategory :: Char -&gt; GeneralCategory</span>. There are about 31 categories so we won't list them all here, but let's play around with the function.</p>
@@ -533,12 +533,12 @@ <h1>Modules</h1>
533533
<p>The most obvious way to represent association lists in Haskell would be by having a list of pairs. The first component in the pair would be the key, the second component the value. Here's an example of an association list with phone numbers:</p>
534534
<pre name="code" class="haskell:hs">
535535
phoneBook =
536-
[("betty","555-2938")
537-
,("bonnie","452-2928")
538-
,("patsy","493-2928")
539-
,("lucille","205-2928")
540-
,("wendy","939-8282")
541-
,("penny","853-2492")
536+
[("amelia","555-2938")
537+
,("freya","452-2928")
538+
,("isabella","493-2928")
539+
,("neil","205-2928")
540+
,("roald","939-8282")
541+
,("tenzing","853-2492")
542542
]
543543
</pre>
544544
<p>Despite this seemingly odd indentation, this is just a list of pairs of strings. The most common task when dealing with association lists is looking up some value by key. Let's make a function that looks up some value given a key.</p>
@@ -562,15 +562,15 @@ <h1>Modules</h1>
562562
</pre>
563563
<div class="hintbox"><em>Note:</em> It's usually better to use folds for this standard list recursion pattern instead of explicitly writing the recursion because they're easier to read and identify. Everyone knows it's a fold when they see the <span class="fixed">foldr</span> call, but it takes some more thinking to read explicit recursion.</div>
564564
<pre name="code" class="haskell:ghci">
565-
ghci&gt; findKey "penny" phoneBook
565+
ghci&gt; findKey "tenzing" phoneBook
566566
Just "853-2492"
567-
ghci&gt; findKey "betty" phoneBook
567+
ghci&gt; findKey "amelia" phoneBook
568568
Just "555-2938"
569-
ghci&gt; findKey "wilma" phoneBook
569+
ghci&gt; findKey "christopher" phoneBook
570570
Nothing
571571
</pre>
572572
<img src="assets/images/modules/legomap.png" alt="legomap" class="left" width="214" height="240">
573-
<p>Works like a charm! If we have the girl's phone number, we <span class="fixed">Just</span> get the number, otherwise we get <span class="fixed">Nothing</span>.</p>
573+
<p>Works like a charm! If we have the friend's phone number, we <span class="fixed">Just</span> get the number, otherwise we get <span class="fixed">Nothing</span>.</p>
574574
<p>We just implemented the <span class="fixed">lookup</span> function from <span class="fixed">Data.List</span>. If we want to find the corresponding value to a key, we have to traverse all the elements of the list until we find it. The <span class="fixed">Data.Map</span> module offers association lists that are much faster (because they're internally implemented with trees) and also it provides a lot of utility functions. From now on, we'll say we're working with maps instead of association lists.</p>
575575
<p>Because <span class="fixed">Data.Map</span> exports functions that clash with the <span class="fixed">Prelude</span> and <span class="fixed">Data.List</span> ones, we'll do a qualified import.
576576
<pre name="code" class="haskell:hs">
@@ -580,8 +580,8 @@ <h1>Modules</h1>
580580
<p>Let's go ahead and see what <span class="fixed">Data.Map</span> has in store for us! Here's the basic rundown of its functions.</p>
581581
<p>The <span class="label function">fromList</span> function takes an association list (in the form of a list) and returns a map with the same associations.</p>
582582
<pre name="code" class="haskell:ghci">
583-
ghci&gt; Map.fromList [("betty","555-2938"),("bonnie","452-2928"),("lucille","205-2928")]
584-
fromList [("betty","555-2938"),("bonnie","452-2928"),("lucille","205-2928")]
583+
ghci&gt; Map.fromList [("amelia","555-2938"),("freya","452-2928"),("neil","205-2928")]
584+
fromList [("amelia","555-2938"),("freya","452-2928"),("neil","205-2928")]
585585
ghci&gt; Map.fromList [(1,2),(3,4),(3,2),(5,5)]
586586
fromList [(1,2),(3,2),(5,5)]
587587
</pre>
@@ -655,19 +655,19 @@ <h1>Modules</h1>
655655
[(4,3),(9,2)]
656656
</pre>
657657
<p><span class="label function">keys</span> and <span class="label function">elems</span> return lists of keys and values respectively. <span class="fixed">keys</span> is the equivalent of <span class="fixed">map fst . Map.toList</span> and <span class="fixed">elems</span> is the equivalent of <span class="fixed">map snd . Map.toList</span>.</p>
658-
<p><span class="label function">fromListWith</span> is a cool little function. It acts like <span class="fixed">fromList</span>, only it doesn't discard duplicate keys but it uses a function supplied to it to decide what to do with them. Let's say that a girl can have several numbers and we have an association list set up like this.</p>
658+
<p><span class="label function">fromListWith</span> is a cool little function. It acts like <span class="fixed">fromList</span>, only it doesn't discard duplicate keys but it uses a function supplied to it to decide what to do with them. Let's say that a friend can have several numbers and we have an association list set up like this.</p>
659659
<pre name="code" class="haskell:hs">
660660
phoneBook =
661-
[("betty","555-2938")
662-
,("betty","342-2492")
663-
,("bonnie","452-2928")
664-
,("patsy","493-2928")
665-
,("patsy","943-2929")
666-
,("patsy","827-9162")
667-
,("lucille","205-2928")
668-
,("wendy","939-8282")
669-
,("penny","853-2492")
670-
,("penny","555-2111")
661+
[("amelia","555-2938")
662+
,("amelia","342-2492")
663+
,("freya","452-2928")
664+
,("isabella","493-2928")
665+
,("isabella","943-2929")
666+
,("isabella","827-9162")
667+
,("neil","205-2928")
668+
,("roald","939-8282")
669+
,("tenzing","853-2492")
670+
,("tenzing","555-2111")
671671
]
672672
</pre>
673673
<p>Now if we just use <span class="fixed">fromList</span> to put that into a map, we'll lose a few numbers! So here's what we'll do:</p>
@@ -676,11 +676,11 @@ <h1>Modules</h1>
676676
phoneBookToMap xs = Map.fromListWith (\number1 number2 -&gt; number1 ++ ", " ++ number2) xs
677677
</pre>
678678
<pre name="code" class="haskell:hs">
679-
ghci&gt; Map.lookup "patsy" $ phoneBookToMap phoneBook
679+
ghci&gt; Map.lookup "isabella" $ phoneBookToMap phoneBook
680680
"827-9162, 943-2929, 493-2928"
681-
ghci&gt; Map.lookup "wendy" $ phoneBookToMap phoneBook
681+
ghci&gt; Map.lookup "roald" $ phoneBookToMap phoneBook
682682
"939-8282"
683-
ghci&gt; Map.lookup "betty" $ phoneBookToMap phoneBook
683+
ghci&gt; Map.lookup "amelia" $ phoneBookToMap phoneBook
684684
"342-2492, 555-2938"
685685
</pre>
686686
<p>If a duplicate key is found, the function we pass is used to combine the values of those keys into some other value. We could also first make all the values in the association list singleton lists and then we can use <span class="fixed">++</span> to combine the numbers.</p>
@@ -689,7 +689,7 @@ <h1>Modules</h1>
689689
phoneBookToMap xs = Map.fromListWith (++) $ map (\(k,v) -&gt; (k,[v])) xs
690690
</pre>
691691
<pre name="code" class="haskell:ghci">
692-
ghci&gt; Map.lookup "patsy" $ phoneBookToMap phoneBook
692+
ghci&gt; Map.lookup "isabella" $ phoneBookToMap phoneBook
693693
["827-9162","943-2929","493-2928"]
694694
</pre>
695695
<p>Pretty neat! Another use case is if we're making a map from an association list of numbers and when a duplicate key is found, we want the biggest value for the key to be kept.</p>

markdown/generated_html/introduction.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ <h2 id="so-whats-haskell">So what’s Haskell?</h2>
136136
lot of high level concepts, Haskell programs are usually shorter than
137137
their imperative equivalents. And shorter programs are easier to
138138
maintain than longer ones and have less bugs.</p>
139-
<p>Haskell was made by some <strong>really smart guys</strong> (with
139+
<p>Haskell was made by some <strong>really smart folk</strong> (with
140140
PhDs). Work on Haskell began in 1987 when a committee of researchers got
141141
together to design a kick-ass language. In 2003 the Haskell Report was
142142
published, which defines a stable version of the language.</p>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -728,12 +728,12 @@ <h2 id="type-synonyms">Type synonyms</h2>
728728
key-value pairs. Let’s look at a phonebook that we had.</p>
729729
<pre class="haskell:hs"><code>phoneBook :: [(String,String)]
730730
phoneBook =
731-
[(&quot;betty&quot;,&quot;555-2938&quot;)
732-
,(&quot;bonnie&quot;,&quot;452-2928&quot;)
733-
,(&quot;patsy&quot;,&quot;493-2928&quot;)
734-
,(&quot;lucille&quot;,&quot;205-2928&quot;)
735-
,(&quot;wendy&quot;,&quot;939-8282&quot;)
736-
,(&quot;penny&quot;,&quot;853-2492&quot;)
731+
[(&quot;amelia&quot;,&quot;555-2938&quot;)
732+
,(&quot;freya&quot;,&quot;452-2928&quot;)
733+
,(&quot;isabella&quot;,&quot;493-2928&quot;)
734+
,(&quot;neil&quot;,&quot;205-2928&quot;)
735+
,(&quot;roald&quot;,&quot;939-8282&quot;)
736+
,(&quot;tenzing&quot;,&quot;853-2492&quot;)
737737
]</code></pre>
738738
<p>We see that the type of <code>phoneBook</code> is
739739
<code>[(String,String)]</code>. That tells us that it’s an association
@@ -782,7 +782,7 @@ <h2 id="type-synonyms">Type synonyms</h2>
782782
<code>Map Int String</code> or if we’re dealin’ with one of them
783783
polymorphic functions, <code>[a]</code> or
784784
<code>(Ord a) =&gt; Maybe a</code> and stuff. And like, sometimes me and
785-
the boys say that <code>Maybe</code> is a type, but we don’t mean that,
785+
my buddies say that <code>Maybe</code> is a type, but we don’t mean that,
786786
cause every idiot knows <code>Maybe</code> is a type constructor. When I
787787
apply an extra type to <code>Maybe</code>, like
788788
<code>Maybe String</code>, then I have a concrete type. You know, values

0 commit comments

Comments
 (0)