Skip to content

Commit 50d0850

Browse files
authored
Merge pull request #5 from bwignall/typeclass
s/typeclass/type class
2 parents 6b5d70a + 5f1c861 commit 50d0850

19 files changed

+206
-200
lines changed

1-getting-started.org

+1-1
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ second case, we ask ~ghci~ to print the type of the expression
906906
without actually evaluating it, so it does not have to be so
907907
specific. It answers, in effect, "its type is numeric". We will
908908
see more of this style of type annotation in
909-
[[file:6-using-typeclasses.org][Chapter 6, /Using Typeclasses/]].
909+
[[file:6-using-typeclasses.org][Chapter 6, Using Type Classes]].
910910

911911
** A simple program
912912

10-parsing-a-binary-data-format.org

+3-3
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ ghci> treeMap (odd . length) tree
653653
Node (Leaf True) (Node (Leaf True) (Leaf False))
654654
#+END_SRC
655655

656-
Haskell provides a well-known typeclass to further generalise
657-
~treeMap~. This typeclass is named ~Functor~, and it defines one
656+
Haskell provides a well-known type class to further generalise
657+
~treeMap~. This type class is named ~Functor~, and it defines one
658658
function, ~fmap~.
659659

660660
#+CAPTION: TreeMap.hs
@@ -748,7 +748,7 @@ instance Functor Bar where
748748
#+END_SRC
749749

750750
This says that we can only put a type ~a~ into a ~Foo~ if ~a~ is a
751-
member of the ~Eq~ typeclass. However, the constraint renders it
751+
member of the ~Eq~ type class. However, the constraint renders it
752752
impossible to write a ~Functor~ instance for ~Bar~.
753753

754754
#+BEGIN_SRC screen

11-testing-and-quality-assurance.org

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ tedious, and violates the moral code of the efficient functional
101101
programmer: let the machine do the work! To automate this the
102102
QuickCheck library comes with a set of data generators for all the
103103
basic Haskell data types. QuickCheck uses the ~Arbitrary~
104-
typeclass to present a uniform interface to (pseudo-)random data
104+
type class to present a uniform interface to (pseudo-)random data
105105
generation with the type system used to resolve which generator to
106106
use. QuickCheck normally hides the data generation plumbing,
107107
however we can also run the generators by hand to get a sense for

12-barcode-recognition.org

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ luminance (r,g,b) = round (r' * 0.30 + g' * 0.59 + b' * 0.11)
559559
b' = fromIntegral b
560560
#+END_SRC
561561

562-
Haskell arrays are members of the ~Functor~ typeclass, so we can
562+
Haskell arrays are members of the ~Functor~ type class, so we can
563563
simply use ~fmap~ to turn an entire image, or a single scanline,
564564
from colour into greyscale.
565565

13-data-structures.org

+7-7
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,8 @@ is. We've shown you a lot of ways to use that power. Here's a
488488
chance to really see that in action.
489489

490490
Back in [[file:6-using-typeclasses.org::*Numeric Types][the section called "Numeric Types"]]
491-
typeclasses that come with Haskell. Let's see what we can do by
492-
defining new types and utilizing the numeric typeclasses to
491+
type classes that come with Haskell. Let's see what we can do by
492+
defining new types and utilizing the numeric type classes to
493493
integrate them with basic mathematics in Haskell.
494494

495495
Let's start by thinking through what we'd like to see out of
@@ -701,7 +701,7 @@ as valid as a ~SymbolicManip Int~ as it as an ~Int~.
701701
From here, then, our task is simple: extend the ~SymbolicManip~
702702
type to be able to represent all the operations we will want to
703703
perform, implement instances of it for the other numeric
704-
typeclasses, and implement our own instance of ~Show~ for
704+
type classes, and implement our own instance of ~Show~ for
705705
~SymbolicManip~ that renders this tree in a more accessible
706706
fashion.
707707

@@ -942,7 +942,7 @@ Now it may become clear why we use a ~SymbolicManip~ instead of a
942942
multiplication occur, the unit of measure also changes. For
943943
instance, if we multiply 5 meters by 2 meters, we obtain 10 square
944944
meters. We force the units for addition to match, and implement
945-
subtraction in terms of addition. Let's look at more typeclass
945+
subtraction in terms of addition. Let's look at more type class
946946
instances for ~Units~.
947947

948948
#+CAPTION: num.hs
@@ -1334,7 +1334,7 @@ binary operator and zero as the identity value, integers form a
13341334
monoid. With multiplication as the binary operator and one as the
13351335
identity value, integers form a different monoid.
13361336

1337-
Monoids are ubiquitous in Haskell[fn:3]. The ~Monoid~ typeclass is
1337+
Monoids are ubiquitous in Haskell[fn:3]. The ~Monoid~ type class is
13381338
defined in the ~Data.Monoid~ module.
13391339

13401340
#+CAPTION: Monoid.hs
@@ -1545,7 +1545,7 @@ If we want to create a list from a ~Seq~, we must use the
15451545
import qualified Data.Foldable as Foldable
15461546
#+END_SRC
15471547

1548-
This module defines a typeclass, ~Foldable~, which ~Seq~
1548+
This module defines a type class, ~Foldable~, which ~Seq~
15491549
implements.
15501550

15511551
#+BEGIN_SRC screen
@@ -1574,7 +1574,7 @@ well.
15741574
** Footnotes
15751575

15761576
[fn:1] The type we use for the key must be a member of the ~Eq~
1577-
typeclass.
1577+
type class.
15781578

15791579
[fn:2] Non-strict evaluation makes the cost calculation
15801580
more subtle. We only pay for an append if we actually use the

14-using-parsec.org

+2-2
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ $ runhaskell csv7.hs < test.csv
644644
** Parsec and MonadPlus
645645

646646
Parsec's ~GenParser~ monad is an instance of the ~MonadPlus~
647-
typeclass that we introduced in
647+
type class that we introduced in
648648
[[file:16-programming-with-monads.org::*Looking for alternatives][the section called "Looking for alternatives"]]
649649
represents a parse failure, while ~mplus~ combines two alternative
650650
parses into one, using ~(<|>)~.
@@ -786,7 +786,7 @@ effort of coming to grips with the idea.
786786
** Applicative functors for parsing
787787

788788
The standard Haskell libraries include a module named
789-
~Control.Applicative~, which defines a typeclass named
789+
~Control.Applicative~, which defines a type class named
790790
~Applicative~, which represents an /applicative functor/. Because
791791
every applicative functor is also a functor they are represented
792792
as a hierarchy.

15-monads.org

+14-14
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ programming patterns have a monadic structure: passing around
224224
implicit data, or short-circuiting a chain of evaluations if one
225225
fails, to choose but two.
226226

227-
** The Monad typeclass
227+
** The Monad type class
228228

229229
We can capture the notions of chaining and injection, and the
230-
types that we want them to have, in a Haskell typeclass. The
231-
standard ~Prelude~ already defines just such a typeclass, named
230+
types that we want them to have, in a Haskell type class. The
231+
standard ~Prelude~ already defines just such a type class, named
232232
~Monad~.
233233

234234
#+BEGIN_SRC haskell
@@ -263,7 +263,7 @@ behavior to its name is that it /returns/ a pure value (of type
263263
~a~) into a monad (of type ~m a~).
264264

265265
While ~(>>=)~ and ~return~ are the core functions of the ~Monad~
266-
typeclass, it also defines two other functions. The first is
266+
type class, it also defines two other functions. The first is
267267
~(>>)~. Like ~(>>=)~, it performs chaining, but it ignores the
268268
value on the left.
269269

@@ -367,10 +367,10 @@ familiar with. These aren't formal terms, but they're in common
367367
use, so it's helpful to know about them.
368368

369369
- "Monadic" simply means "pertaining to monads". A monadic /type/
370-
is an instance of the ~Monad~ typeclass; a monadic /value/ has a
370+
is an instance of the ~Monad~ type class; a monadic /value/ has a
371371
monadic type.
372372
- When we say that a type "is a monad", this is really a shorthand
373-
way of saying that it's an instance of the ~Monad~ typeclass.
373+
way of saying that it's an instance of the ~Monad~ type class.
374374
Being an instance of ~Monad~ gives us the necessary monadic
375375
triple of type constructor, injection function, and chaining
376376
function.
@@ -388,7 +388,7 @@ use, so it's helpful to know about them.
388388

389389
In our introduction to monads, we showed how some pre-existing
390390
code was already monadic in form. Now that we are beginning to
391-
grasp what a monad is, and we've seen the ~Monad~ typeclass, let's
391+
grasp what a monad is, and we've seen the ~Monad~ type class, let's
392392
build a monad with foreknowledge of what we're doing. We'll start
393393
out by defining its interface, then we'll put it to use. Once we
394394
have those out of the way, we'll finally build it.
@@ -461,7 +461,7 @@ runLogger :: Logger a -> (a, Log)
461461

462462
*** Controlled escape
463463

464-
The ~Monad~ typeclass doesn't provide any means for values to
464+
The ~Monad~ type class doesn't provide any means for values to
465465
escape their monadic shackles. We can inject a value into a monad
466466
using ~return~. We can extract a value from a monad using ~(>>=)~
467467
but the function on the right, which can see an unwrapped value,
@@ -658,7 +658,7 @@ functor, calling the function on it, and rewrapping the result
658658
with the same constructor.
659659

660660
We do exactly the same thing with a monad. Because the ~Monad~
661-
typeclass already provides the ~(>>=)~ and ~return~ functions that
661+
type class already provides the ~(>>=)~ and ~return~ functions that
662662
know how to unwrap and wrap a value, the ~liftM~ function doesn't
663663
need to know any details of a monad's implementation.
664664

@@ -670,7 +670,7 @@ liftM f m = m >>= \i ->
670670
#+END_SRC
671671

672672
When we declare a type to be an instance of the ~Functor~
673-
typeclass, we have to write our own version of ~fmap~ specially
673+
type class, we have to write our own version of ~fmap~ specially
674674
tailored to that type. By contrast, ~liftM~ doesn't need to know
675675
anything of a monad's internals, because they're abstracted by
676676
~(>>=)~ and ~return~. We only need to write it once, with the
@@ -849,7 +849,7 @@ flavours, each with different levels of strictness.
849849
Our ~Logger~ monad is a specialised version of the standard
850850
~Writer~ monad, which can be found in the ~Control.Monad.Writer~
851851
module of the ~mtl~ package. We will present a ~Writer~ example in
852-
[[file:16-programming-with-monads.org::*Using typeclasses][the section called "Using typeclasses"]]
852+
[[file:16-programming-with-monads.org::*Using type classes][the section called "Using type classes"]]
853853

854854
** The Maybe monad
855855

@@ -1631,14 +1631,14 @@ rand = getStdRandom (randomR (0, maxBound))
16311631
(The ~randomR~ function takes an inclusive range within which the
16321632
generated random value should lie.)
16331633

1634-
The ~System.Random~ module provides a typeclass, ~RandomGen~, that
1634+
The ~System.Random~ module provides a type class, ~RandomGen~, that
16351635
lets us define new sources of random ~Int~ values. The type
16361636
~StdGen~ is the standard ~RandomGen~ instance. It generates
16371637
pseudorandom values. If we had an external source of truly random
16381638
data, we could make it an instance of ~RandomGen~ and get truly
16391639
random, instead of merely pseudorandom, values.
16401640

1641-
Another typeclass, ~Random~, indicates how to generate random
1641+
Another type class, ~Random~, indicates how to generate random
16421642
values of a particular type. The module defines ~Random~ instances
16431643
for all of the usual simple types.
16441644

@@ -1882,7 +1882,7 @@ conventionally named ~join~.
18821882
If we had definitions of ~join~ and ~fmap~, we wouldn't need to
18831883
write a definition of ~(>>=)~ for every monad, because it would be
18841884
completely generic. Here's what an alternative definition of the
1885-
~Monad~ typeclass might look like, along with a definition of
1885+
~Monad~ type class might look like, along with a definition of
18861886
~(>>=)~.
18871887

18881888
#+BEGIN_SRC haskell

0 commit comments

Comments
 (0)