Get Haskell The Ultimate Beginner s Guide to Learn Haskell Programming Step by Step 1st Edition Claudia Alves PDF ebook with Full Chapters Now
Get Haskell The Ultimate Beginner s Guide to Learn Haskell Programming Step by Step 1st Edition Claudia Alves PDF ebook with Full Chapters Now
Get Haskell The Ultimate Beginner s Guide to Learn Haskell Programming Step by Step 1st Edition Claudia Alves PDF ebook with Full Chapters Now
com
https://textbookfull.com/product/haskell-the-
ultimate-beginner-s-guide-to-learn-haskell-
programming-step-by-step-1st-edition-claudia-
alves/
https://textbookfull.com/product/lua-programming-the-ultimate-
beginner-s-guide-to-learn-lua-step-by-step-3rd-edition-claudia-alves/
textbookfull.com
https://textbookfull.com/product/the-ultimate-beginner-s-guide-to-
learn-kotlin-programming-step-by-step-2020-2nd-edition-moaml-mohmmed/
textbookfull.com
https://textbookfull.com/product/go-programming-language-the-ultimate-
beginner-s-guide-to-learn-go-programming-step-by-step-3rd-edition-
john-bach/
textbookfull.com
https://textbookfull.com/product/urban-storm-water-management-second-
edition-pazwash/
textbookfull.com
Thomas S Szasz The Man and His Ideas 1st Edition Jeffrey
A. Schaler
https://textbookfull.com/product/thomas-s-szasz-the-man-and-his-
ideas-1st-edition-jeffrey-a-schaler/
textbookfull.com
https://textbookfull.com/product/marketing-research-7th-edition-alvin-
burns/
textbookfull.com
https://textbookfull.com/product/lpi-linux-essentials-study-guide-
exam-010-v1-6-3rd-edition-christine-bresnahan/
textbookfull.com
https://textbookfull.com/product/growing-up-and-out-of-crime-
desistance-maturation-and-emerging-adulthood-1st-edition-elias-s-
nader-2/
textbookfull.com
https://textbookfull.com/product/television-field-production-and-
reporting-a-guide-to-visual-storytelling-7th-edition-fred-shook/
textbookfull.com
Window on Humanity: A Concise Introduction to General
Anthropology Conrad Kottak
https://textbookfull.com/product/window-on-humanity-a-concise-
introduction-to-general-anthropology-conrad-kottak/
textbookfull.com
Haskell
The Ultimate Beginner's Guide to Learn Haskell Programming Step by Step
1st edition
2020
By Claudia Alves
"Programming isn't about what you know; it's
about what you can figure out.” - Chris Pine
memlnc
INTRODUCTION
WHAT MAKES HASKELL SPECIAL?
HOW IS HASKELL USED?
WHAT DO YOU NEED TO START
STARTING
READY, SET, GO!
THE FIRST SMALL FUNCTIONS
AN INTRODUCTION TO THE LISTS
TEXAS RANGES
I'M AN INTENSIONAL LIST
TUPLES
CHAPTER I
TYPES AND TYPE CLASSES
BELIEVE IN THE TYPE
TYPE VARIABLES
TYPE CLASSES STEP BY STEP (1ST PART)
CHAPTER II
THE SYNTAX OF FUNCTIONS
PATTERN ADJUSTMENT
GUARDIANS, GUARDIANS!
WHERE?
LET IT BE
CASE EXPRESSIONS
CHAPTER III
RECURSION
HELLO RECURSION!
THE IMPRESSIVE MAXIMUM
A FEW MORE RECURSIVE FUNCTIONS
QUICKSORT!
THINKING RECURSIVELY
CHAPTER IV
HIGHER ORDER FUNCTIONS
CURRIFIED FUNCTIONS
HIGHER ORDER IN YOUR ORDER
ASSOCIATIONS AND FILTERS
LAMBDAS
FOLDS AND ORIGAMI
APPLICATION OF FUNCTIONS WITH $
COMPOSITION OF FUNCTIONS
CHAPTER V
MODULES
LOADING MODULES
DATA.LIST
DATA.CHAR
DATA.MAP
DATA.SET
CREATING OUR OWN MODULES
CHAPTER VI
CREATING OUR OWN TYPES AND TYPE
CLASSES
INTRODUCTION TO ALGEBRAIC DATA TYPES
REGISTRATION SYNTAX
TYPE PARAMETERS
DERIVED INSTANCES
TYPE SYNONYMS
RECURSIVE DATA STRUCTURES
TYPE CLASSES STEP BY STEP (2ND PART)
THE YES-NO TYPE CLASS
THE FUNCTOR TYPE CLASS
FAMILIES AND MARTIAL ARTS
CHAPTER VII
INPUT AND OUTPUT
HELLO WORLD!
FILES AND DATA STREAMS
COMMAND LINE PARAMETERS
RANDOMNESS
BYTE STRINGS
EXCEPTIONS
Introduction
A balance of flexible and inflexible qualities make Haskell a fascinating
programming language to learn and use.
First, the Haskell programming language is not named after Eddie Haskell,
the sneaky double-dealing neighbor kid in the ancient TV sitcom, Leave It To
Beaver.
Haskell the language is built around functions, useful blocks of code that do
specific tasks. They are called and used only when needed.
Perhaps what makes Haskell special is how coders have to think when they
use the language. Functional programming languages work in very different
ways than imperative languages where the coder manages many low-level
details of what happens in their code and when. While it is true all languages
have things in common, it’s also true languages are mostly functional or
mostly imperative, the way people are mostly right handed or left handed.
Except functional programming languages require a different way of thinking
about software as you code.
- No side effects. In other languages, code can affect the state of the
computer and application, for example, writing to a file. Haskell strictly
limits these side effects which, in turn, makes Haskell applications less
prone to errors.
Building from small bits of code, each bit tightly contained and testable.
So what is Haskell?
Haskell is lazy . That is, unless we tell you otherwise, Haskell will not
execute functions or calculate results until you are really forced to. This
works very well in conjunction with referential transparency and allows us to
view programs as a series of data transformations. It even allows us to do
cool things like infinite data structures. Let's say we have a list of immutable
numbers xs = [1,2,3,4,5,6,7,8] and a doubleMe function that multiplies each item
by 2 and returns a new list. If we wanted to multiply our list by 8 in an
imperative language if we did doubleMe (doubleMe (doubleMe (xs))) , the computer
would probably loop through the list, make a copy and return the value. Then
it would go through the list two more times and return the final value. In lazy
language, calling doubleMe with an unforced list to display the value ends up
with a program telling you "Sure, sure, then I'll do it!". But when you want to
see the result, the first doubleMe tells the second one that he wants the result,
now! The second says the same to the third and the latter reluctantly returns a
duplicate 1, which is a 2. The second receives it and returns a 4 to the first.
The first one sees the result and says that the first item in the list is an 8. In
this way, the computer only makes a journey through the list and only when
we need it. When we want to calculate something from initial data in lazy
language, we just have to take this data and transform and mold it until it
resembles the result we want.
Starting
Ready, Set, Go!
Alright, let's get started! If you are that kind of bad person who doesn't read
the introductions and you have skipped it, you may want to read the last
section of the introduction because it explains what you need to follow this
guide and how we are going to work. The first thing we are going to do is run
GHC in interactive mode and use some functions to get used to it a little.
Open a terminal and type ghci . You will be greeted with a greeting like this:
GHCi, version 7.2.1: http://www.haskell.org/ghc/:? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude>
Congratulations, you came from GHCi! Here the pointer (or prompt ) is
Prelude> but since it gets longer as we load modules during a session, we are
going to use ghci> . If you want to have the same pointer execute : set prompt
"ghci> " .
Here we have some simple arithmetic.
ghci> 2 + 15
17
ghci> 49 * 100
4900
ghci> 1892 - 1472
420
ghci> 5/2
2.5
ghci>
It is self explanatory. We can also use several operations on the same line so
that all the rules of precedence that we all know are followed. We can use
parentheses to use explicit precedence.
ghci> (50 * 100) - 4999
one
ghci> 50 * 100 - 4999
one
ghci> 50 * (100 - 4999)
-244950
Very interesting, huh? Yes, I know not, but be patient. A small difficulty to
keep in mind occurs when we deny numbers, it will always be better to
surround negative numbers with parentheses. Doing something like 5 * -3
will make GHCi angry, however 5 * (-3) will work.
Boolean algebra is also quite simple. As you probably know, && represents
the logical AND while || represents the logical OR . not denies True to False
and vice versa.
ghci> True && False
False
ghci> True && True
True
ghci> False || True
True
ghci> not False
True
ghci> not (True && True)
False
The equality check is done like this:
ghci> 5 == 5
True
ghci> 1 == 0
False
ghci> 5 / = 5
False
ghci> 5 / = 4
True
ghci> "hello" == "hello"
True
What if we do something like 5 + "text" or 5 == True ? Well, if we try the
first one we get this friendly error message:
No instance for (Num [Char])
arising from a use of `+ 'at <interactive>: 1: 0-9
Possible fix: add an instance declaration for (Num [Char])
In the expression: 5 + "text"
In the definition of `it ': it = 5 +" text "
GHCi is telling us that "text" is not a number and therefore does not know
how to add it to 5. Even if instead of "text" it were "four" , "four" , or "4" ,
Haskell would not consider it as a number. + expects its left and right sides to
be numbers. If we try to perform True == 5 , GHCi would tell us that the
types do not match. While + works only with things that are considered
numbers, == works with anything that can be compared. The trick is that both
must be comparable to each other. We can't compare speed with bacon. We'll
take a more detailed look at the types later. Note: we can do 5 + 4.0 because 5
does not have a specific type and can act as an integer or as a floating point
number. 4.0 cannot act as an integer, so 5 is the only one that can be adapted.
You may not know it, but we have been using functions all this time. For
example, * is a function that takes two numbers and multiplies them. As you
have already seen, we call him making a sandwich on him. We call this infix
functions. Many functions that are not used with numbers are prefixes. Let's
see some of them.
Functions are normally prefixes so from now on we are not going to say that
a function is in prefix form, we will just assume it. In many imperative
languages functions are called by writing their names and then writing their
parameters in parentheses, usually separated by commas. In Haskell,
functions are called by typing their name, a space, and their parameters,
separated by spaces. For starters, let's try calling one of Haskell's most boring
functions.
ghci> succ 8
9
The succ function takes anything that has a successor defined and returns that
successor. As you can see, we have simply separated the function name and
its parameter by a space. Calling a function with multiple parameters is just
as easy. The min and max functions take two things that can be put in order
(like numbers!) And return one of them.
ghci> min 9 10
9
ghci> min 3.4 3.2
3.2
ghci> max 100 101
101
The application of functions (calling a function by putting a space after it and
then writing its parameters) has the highest priority. Said with an example,
these two sentences are equivalent:
We have just introduced the Haskell if statement . You are probably already
familiar with the if statement from other languages. The difference between
Haskell's if statement and that of imperative languages is that the else part is
mandatory. In imperative languages we can skip a few steps if a condition is
not satisfied, but in Haskell each expression or function must return a value.
We could also have defined the if statement on a single line but it seems a bit
more readable that way. Another thing about the if statement in Haskell is
that it is an expression. Basically an expression is a piece of code that returns
a value. 5 is an expression because it returns 5, 4 + 8 is an expression, x + y is
an expression because it returns the sum of x and y . Since the else part is
mandatory, an if statement will always return something and is therefore an
expression. If we want to add one to each number that is produced by the
previous function, we can write its body like this.
doubleSmallNumber ' x = ( if x > 100 then x else x * 2 ) + 1
If we had omitted the parentheses, I would have only added one if x was not
greater than 100. Look at the ' at the end of the function name. That
apostrophe has no special meaning in Haskell's syntax. It is a valid character
to be used in the name of a function. We usually use ' to denote the strict
version of a function (one that is not lazy) or a small modified version of a
function or variable. Since ' is a valid character for functions, we can do
things like this.
conanO'Brien = "It's me, Conan O'Brien!"
There are two things that remain to be highlighted. The first is that the name
of this function does not begin with capital letters. This is because functions
cannot start with an uppercase letter. We will see why a little later. The
second is that this function does not take any parameters, we usually call it a
definition (or a name). Since we can't change definitions (and functions) after
we've defined them, conanO'Brien and the string "It's a-me, Conan O'Brien!"
they can be used interchangeably.
An introduction to the lists
Like real-life shopping lists, lists in Haskell are very helpful. It is the most
widely used data structure and can be used in different ways to model and
solve a lot of problems. The lists are VERY important. In this section we will
take a look at the basics about lists, text strings (which are lists) and
intensional lists.
In Haskell, lists are a homogeneous data structure . Stores multiple items of
the same type. This means that we can create an integer list or a character list,
but we cannot create a list that has a few integers and a few other characters.
And now, a list!
Note
We can use the let keyword to define a name in GHCi. Doing let a = 1 inside
GHCi is equivalent to writing a = 1 to a file and then loading it.
ghci> let lostNumbers = [4,8,15,16,23,42]
ghci> lostNumbers
[4,8,15,16,23,42]
As you can see, the lists are defined by square brackets and their values are
separated by commas. If we tried to create a list like this [1,2, 'a', 3, 'b', 'c', 4] ,
Haskell would warn us that the characters (which by the way are declared as
a character in single quotes) are not numbers. Speaking of characters, strings
are simply lists of characters. "hello" is just a syntactic alternative to ['h', 'e',
'l', 'l', 'o'] . Since the strings are lists, we can use the functions that operate
with lists on them, which is really useful.
A common task is to concatenate two lists. Which we did with the ++
operator .
But if we try to get the sixth item in a list that only has four items, we will get
an error, so be careful.
Lists can also contain lists. These can also contain lists that contain lists, that
contain lists ...
The lists within the lists can have different sizes but cannot have different
types. In the same way that you cannot contain characters and numbers in a
list, you cannot contain lists that contain character lists and number lists
either.
The lists can be compared if the elements they contain can be compared.
When we use < , <= , > , and > = to compare lists, they are compared in
lexicographic order. The heads are first compared. Then the second elements
are compared and so on.
What else can we do with the lists? Here are some basic functions that can
operate with lists.
head takes a list and returns its head. The head of a list is basically the first element.
ghci> head [5,4,3,2,1]
5
tail takes a list and returns its tail. In other words, cut off the head of the list.
ghci> tail [5,4,3,2,1]
[4,3,2,1]
last takes a list and returns its last element.
ghci> last [5,4,3,2,1]
one
init takes a list and returns the entire list except its last element.
ghci> init [5,4,3,2,1]
[5,4,3,2]
Note that if we try to take more elements than there are in a list, it
simply returns the list. If we take 0 elements, we get an empty list.
drop works similarly, except that it removes a number of items from the beginning of the
list.
ghci> drop 3 [8,4,2,1,5,6]
[1,5,6]
ghci> drop 0 [1,2,3,4]
[1,2,3,4]
ghci> drop 100 [1,2,3,4]
[]
maximum takes a list of things that can be put in some sort of order and returns the
largest element.
minimum returns the smallest.
ghci> minimum [8,4,2,1,5,6]
one
ghci> maximum [1,9,2,3,4]
9
sum takes a list of numbers and returns their sum.
product takes a list of numbers and returns your product.
ghci> sum [5,2,1,6,3,2,5,7]
31
ghci> product [6,2,1,2]
24
ghci> product [1,2,5,6,7,9,2,0]
0
elem takes a thing and a list of things and tells us if that thing is an element of the list.
This function is normally called infixed because it is easier to read.
ghci> 4 `elem` [3,4,5,6]
True
ghci> 10 `elem` [3,4,5,6]
False
These were a few basic functions that operate with lists. We will see more
functions that operate with lists later.
Texas ranges
What if we want a list with all the numbers between 1 and 20? Yes, we could
just write them all but obviously this is not a solution for those who are
looking for good programming languages. Instead, we will use ranges.
Ranges are a way to create lists that contain an arithmetic sequence of
enumerable elements. The numbers can be numbered. One, two, three, four,
etc. Characters can also be numbered. The alphabet is an enumeration of
characters from A to Z. The names are not enumerable. What comes after
"Juan"? No idea.
To create a list containing all the natural numbers from 1 to 20 we simply
write [1..20] . It is equivalent to writing
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] and there is no
difference between typing one or the other except that manually typing a long
sequence of enumerables is pretty stupid.
ghci> [1..20]
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
ghci> ['a' .. 'z']
"ABCDEFGHIJKLMNOPQRSTU VWXYZ"
ghci> ['K' .. 'Z']
"KLMNOPQRSTUVWXYZ"
We can also specify the number of steps between elements of a range. What
if we want all the even numbers from 1 to 20? Or every third number?
ghci> [2,4..20]
[2,4,6,8,10,12,14,16,18,20]
ghci> [3,6..20]
[3,6,9,12,15,18]
It is a matter of separating the first two elements with a comma and then
specifying the upper limit. Although they are smart, the step ranges are not as
smart as some people expect them to be. You cannot type [1,2,4,8,16..100]
and expect to get all powers of 2. First because only one step can be
specified. And second, because the sequences that are not arithmetic are
ambiguous if we only give a few initial elements.
To get a list with all the numbers from 20 to 1 we cannot use [20..1] , we
must use [20,19..1] .
Be careful when using floating point numbers with ranges! These are not
entirely accurate (by definition), and their use with ranges may give some
unexpected results.
ghci> [0.1, 0.3 .. 1]
[0.1.0.3.0.5.0.7.0.8999999999999999.1.0999999999999999]
A s they approached the oil region, and began to see the tall
derricks, looking like windmill towers, crowning the hilltops,
their conversation naturally turned upon the subject of oil and its
production. Arthur related stories from Brace Barlow’s experience;
while Colonel Dale, who, from weeks of reading, was now as well
informed on all matters pertaining to oil as one can be from books
alone, gave them bits of information concerning its early use and
history.
One of Arthur’s stories described the fearfully narrow escape his
“dear giant” once had from a runaway team. He was driving along a
lonely road that ran in the bottom of a narrow valley, and had sixty
quarts of nitro-glycerine snugly stowed under the seat of his buggy.
Suddenly he saw a runaway team attached to a heavy lumber wagon,
dashing at a mad gallop down the road, directly toward him. There
was barely time to turn his own horses into the ditch at one side, and
thus leave a narrow space through which the runaways might have
passed in safety, if they had so chosen.
Instead of doing this, they too headed for the ditch, and plunged
into it, just in front of the glycerine buggy. There they fell over each
other, broke the pole, upset their wagon, and became so entangled in
the wreck that they were incapable of further mischief. All this took
place within ten feet of where Brace Barlow sat, on top of his load of
nitro-glycerine, as steadily as though he did not expect, with each
instant, to be blown into a million fragments, and hurled into
eternity.
Then Colonel Dale explained what torpedoes are, and why they are
used; and Miss Hatty said she hoped their well would have to be
shot, so that she might witness the operation. Seeing that his
companions were interested in the subject, the Colonel continued to
talk of it. He said:
“Although we, naturally, know and hear more about the oil fields
of Pennsylvania than any other, petroleum is also found in a dozen or
more of our own States and territories, as well as in many other
countries of the world. In Pennsylvania it exists in a narrow territory,
lying about fifty miles west of the Alleghany Mountains; and, as the
oil-bearing belt extends in a general northeast and southwest
direction, it is spoken of as lying on a forty-five-degree line.”
“Just as our farm does,” said Arthur.
“Exactly,” said his grandfather, “and I only hope it may not lie over
one of the many barren places that exist on that line.”
“In this part of the country,” he continued, “the drilling of wells
and the handling of oil have been reduced to a state of perfection and
simplicity unknown elsewhere. Consequently, Pennsylvania well
drillers, with their tools, are in demand in many foreign oil fields,
and may be found, commanding large salaries, in Russia, Japan,
China, New Zealand, Canada, the various countries of Western South
America, in several of the West Indian islands, and elsewhere.
“In China immense oil fields exist, in which wells, drilled centuries
ago, are still in use. Natural gas has also been used in that country for
hundreds, and perhaps thousands, of years. It is conveyed from the
wells through bamboo pipes tipped with rude clay burners.
“Petroleum has also been known and used in Burmah for an
unknown length of time, both for light and fuel. Into a shallow oil
well of that country an iron bucket is lowered by means of a rope,
passing over a wooden cylinder. When the bucket is full, two men
take hold of the other end of the rope, and, by running down an
inclined plane as long as the well is deep, draw it to the surface.”
“What a stupid way,” said Miss Hatty.
“Havana, Cuba,” continued Colonel Dale, “was originally named
‘Carine,’ for it was the place where the early voyagers to the new
world careened their vessels and made their seams water-tight with
the natural pitch, or solidified petroleum, that oozed in abundance
from the rocks near the shores of the harbor. Oil springs are very
numerous in Cuba, as they are in many others of the West Indian
islands.”
“Wouldn’t it be good if we could find a flowing oil spring on our
farm?” said Arthur, his eyes glistening at the prospect.
“It would certainly be very pleasant,” replied his grandfather.
“And, speaking of flowing springs, the most wonderful flow of
petroleum ever seen in any country, occurred in 1862 in the town of
Enniskillen, in the western part of the Canadian Province of Ontario,
along the borders of a stream called Black Creek. At that time there
was so little demand for oil that it was only bringing ten cents a
barrel, though three years later it was worth ten dollars a barrel in
gold.
“The first well in that region was drilled early in the year; and, at
the depth of only one hundred feet, it entered an immense reservoir
of petroleum. Although oil was of so little value at that time, the
reckless settlers of the country seemed possessed of a rage for
drilling wells, apparently merely for the pleasure of seeing it flow
from them. Some of these rudely drilled wells spouted forth
thousands of barrels of oil in a day, and one of them is computed to
have flowed at the rate of 10,000 barrels in twenty-four hours. All
these fountains and rivers of oil were allowed to run absolutely to
waste. The waters of Black Creek were covered by it to a depth of six
inches, and it formed a film over the entire surface of Lake Erie.
“At length this vast quantity of oil was set on fire by some
mischievous person, who wished to see what the effect would be. For
days Black Creek was a torrent of raging flames, that leaped and
roared with inconceivable fury and grandeur. It was such a sight as
the world never had seen, and probably never will see again; while
the Canadians were so thoroughly satisfied with their experiment
that they have had no desire to repeat it since.
“It is estimated that, during the spring and summer of 1862, no
less than five millions of barrels of oil ran to waste down the channel
of Black Creek. Three years later that amount of oil would have been
worth, in the United States, a hundred million of dollars.”
“My!” exclaimed Arthur, drawing a long breath. “I don’t believe I
should know what to do with so much money as that.”
“I am afraid you wouldn’t, dear,” laughed Miss Hatty. “I know that
I for one would not dare assume the responsibility of taking care of,
and spending, such an enormous sum. Why, the man who has one
hundredth part of that, or one million, has more money than many
princes, and is wealthy beyond the average conception; while he who
has but a thousandth part of it, or one hundred thousand dollars, is
still a rich man.”
Although Arthur hardly comprehended these figures, they
interested him, and he now asked: “How many barrels of oil will we
have to get out of our well, grandpapa, to give us as much money as
we need?”
“That is rather a hard question to answer,” laughed Colonel Dale;
“for, as a general thing, the more money people have, the more they
think they need. However, always supposing that it is not a ‘duster,’
as you have taught me to call a dry hole, if our well yields twenty-five
barrels a day I shall be pleased. If it should yield fifty barrels I should
be perfectly satisfied; while with a daily yield of one hundred barrels,
I should be amazed and delighted. In that case you might well be
called a ‘little oil Prince’; for, with oil at three dollars per barrel, your
income would be at the rate of a hundred thousand dollars a year.”
“But suppose it should yield more than a hundred barrels a day?”
persisted Arthur. “How would you feel then?”
“I am sure I do not know,” laughed his grandfather, “for I cannot
conceive of such a thing as happening. I expect I should feel
something as Mr. Kier of Pittsburgh did in 1860, when the oil that he
had been getting at the rate of two or three barrels a day from his salt
wells, and selling as a medicine for fifty cents a half pint, was
suddenly produced in such quantities that the price fell to about ten
cents per barrel. So, if our well should flow too freely, I should be
afraid that its product would become a drug on the market.”
“Just what Mr. Kier’s had been, but ceased to be,” laughed Miss
Hatty.
“What?” asked Arthur, innocently.
“Why, a drug on the market. Didn’t uncle say that it was formerly
sold as a medicine?”
“Oh, yes,” said Arthur, soberly, “I see.”
Just then Miss Hatty, who was very fond of figs, invested ten cents
in a small box of “fig tablets,” as the train-boy called them. She and
Arthur at once began to eat them with evident relish, but Colonel
Dale refused the proffered box.
“What do you suppose you are eating?” he asked, smiling.
“Why, figs of course,” answered Miss Hatty.
“Do you call that a fig leaf?” asked her uncle, pointing to one, cut
from green paper, that lay on top of the box.
“No, certainly not. That is only an imitation leaf,” was the answer.
“Well, it is just as much a real leaf as those are real figs.”
“Why, grandpapa, they have seeds in them!” exclaimed Arthur, as
though that was proof positive that they must be real figs.
“To be sure they have,” laughed Colonel Dale. “The imitation
would not be a good one if the seeds were left out. In spite of their
seeds, those figs are made of petroleum; or rather of paraffine, which
is one of the important products of petroleum. Not long ago I came
across a list of over two hundred articles of commerce that are
manufactured directly from this wonderful oil. Among them were
these very ‘fig tablets.’ Other things made from paraffine are
chewing-gum, jujube paste, gum-drops, some jellies and jams, icing
for cakes, etc. The list also contained the names of all our most
brilliant dyes, which are produced from the very lowest residuum of
petroleum tar, and several drugs, among which was a powerful
anæsthetic.”
“Well,” said Miss Hatty, “I am glad I am not so wise as some
people. It is very foolish to know too much; for it takes half the
pleasure out of life. Now I am sure I don’t care to eat any more of
these kerosene figs, even if they have got seeds in them; and yet a
minute ago I thought them quite good.”
“Seems to me,” said practical little Arthur, “that it is more foolish
not to eat a thing that tastes good, if it won’t do you any harm, no
matter what it is made of, than it is to be wise.”
“And it seems to me,” said Colonel Dale, “that we had better be
collecting our things and preparing to leave the train; for here is the
station at which we are to get off.”
CHAPTER XXIX.
LOCATING AN OIL WELL.