0% found this document useful (0 votes)
527 views50 pages

Full Functional Programming in Scala, Second Edition (MEAP V08) Michael Pilquist PDF All Chapters

The document promotes the second edition of 'Functional Programming in Scala,' highlighting updates made since the first edition, including inline answers to exercises to aid understanding. It emphasizes the benefits of functional programming, such as modularity and easier testing, by illustrating the transition from impure to pure functions in Scala. Additionally, it provides links to various related ebooks available for immediate download.

Uploaded by

mytebais
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
527 views50 pages

Full Functional Programming in Scala, Second Edition (MEAP V08) Michael Pilquist PDF All Chapters

The document promotes the second edition of 'Functional Programming in Scala,' highlighting updates made since the first edition, including inline answers to exercises to aid understanding. It emphasizes the benefits of functional programming, such as modularity and easier testing, by illustrating the transition from impure to pure functions in Scala. Additionally, it provides links to various related ebooks available for immediate download.

Uploaded by

mytebais
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

Functional Programming in Scala, Second Edition


(MEAP V08) Michael Pilquist

https://ebookmeta.com/product/functional-programming-in-
scala-second-edition-meap-v08-michael-pilquist/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Programming Scala Scalability Functional Programming


Objects Third Edition Wampler Dean

https://ebookmeta.com/product/programming-scala-scalability-
functional-programming-objects-third-edition-wampler-dean/

ebookmeta.com

Learning Concurrent Programming in Scala Second Edition


Aleksandar Prokopec

https://ebookmeta.com/product/learning-concurrent-programming-in-
scala-second-edition-aleksandar-prokopec-2/

ebookmeta.com

Learning Concurrent Programming in Scala Second Edition


Aleksandar Prokopec

https://ebookmeta.com/product/learning-concurrent-programming-in-
scala-second-edition-aleksandar-prokopec/

ebookmeta.com

Below Zero (The STEMinist Novellas #3) 1st Edition Ali


Hazelwood

https://ebookmeta.com/product/below-zero-the-steminist-novellas-3-1st-
edition-ali-hazelwood/

ebookmeta.com
Caged an Omegaverse Reverse Harem Romance Golden Cage
Omegas Book 1 1st Edition Mona Black

https://ebookmeta.com/product/caged-an-omegaverse-reverse-harem-
romance-golden-cage-omegas-book-1-1st-edition-mona-black/

ebookmeta.com

The Lost Dragon Dan Michaelson D K Holmberg

https://ebookmeta.com/product/the-lost-dragon-dan-michaelson-d-k-
holmberg/

ebookmeta.com

Blueprint How DNA Makes Us Who We Are with a new afterword


for the paperback edition Robert Plomin

https://ebookmeta.com/product/blueprint-how-dna-makes-us-who-we-are-
with-a-new-afterword-for-the-paperback-edition-robert-plomin/

ebookmeta.com

Mathematical Methods in Image Processing and Inverse


Problems 1st Edition Xue-Cheng Tai

https://ebookmeta.com/product/mathematical-methods-in-image-
processing-and-inverse-problems-1st-edition-xue-cheng-tai/

ebookmeta.com

We Are Not Broken 1st Edition Nadine Little

https://ebookmeta.com/product/we-are-not-broken-1st-edition-nadine-
little/

ebookmeta.com
Atlas of Emergency Medicine Procedures 2nd Edition Latha
Ganti

https://ebookmeta.com/product/atlas-of-emergency-medicine-
procedures-2nd-edition-latha-ganti/

ebookmeta.com
Functional Programming in Scala, Second Edition
MEAP V08
1. MEAP_VERSION_8
2. Welcome
3. 1_What_is_functional_programming?
4. 2_Getting_started_with_functional_programming_in_Scala
5. 3_Functional_data_structures
6. 4_Handling_errors_without_exceptions
7. 5_Strictness_and_laziness
8. 6_Purely_functional_state
9. 7_Purely_functional_parallelism
10. 8_Property-based_testing
11. 9_Parser_combinators
12. 10_Monoids
13. 11_Monads
14. 12_Applicative_and_traversable_functors
15. 13_External_effects_and_I/O
16. 14_Local_effects_and_mutable_state
17. 15_Stream_processing_and_incremental_I/O
MEAP VERSION 8
Welcome
Thank you for purchasing the MEAP for Functional Programming in Scala,
Second Edition.

The first edition was published in 2014 and quickly became regarded as a
classic text in functional programming. It's been used by university courses
and by study groups, by hobbyists and the by world's largest companies, and
has been translated to different languages. The first edition also had a
reputation for being very difficult, with many readers getting stuck on some
of the exercises.

A lot has changed in Scala since 2014. At the time of publication, Scala 2.10
had been recently released and the Scala FP ecosystem was in its infancy.
Major open source projects like Doobie (http://github.com/tpolecat/doobie)
and http4s (http://http4s.org) were just getting started, the Cats
(http://typelevel.org/cats/) library didn't yet exist, and FS2
(https://github.com/typelevel/fs2), which grew out of the code presented in
chapter 15, was just published. Interoperability between libraries was
cumbersome and the Scala language had some key limitations that made FP
less accessible than it could be.

The second edition of Functional Programming in Scala does not stray far
from the first edition. We cover the same topics and in the same style,
avoiding teaching any specific library and instead focusing on teaching the
underlying concepts that power libraries like Cats, Doobie, http4s, and FS2.
The text has been updated for the release of Scala 3, as well as other changes
that have occurred in the standard library since the original publication using
Scala 2.10. Perhaps controversially, we've decided to include inline,
annotated answers to the exercises. We hope that by doing so, readers that
were discouraged after getting stuck will instead find the inline answers
illuminating and continue with the text. We encourage all readers to try the
exercises before reading the answers though, as practice with FP concepts is
essential to understanding. The exercises and answers, updated for Scala 3,
are also available on the book's Github repository:
http://github.com/fpinscala/fpinscala on the second-edition branch.

We hope you enjoy the second edition of Functional Programming in Scala


and that it lives up to the reputation of the first edition. Finally, we need your
feedback, so please post questions or comments in the liveBook's Discussion
Forum. Doing so will help us make a better book, ultimately improving the
accessibility of functional programming.

— Michael Pilquist, Runar Bjarnason, & Paul Chiusano

In this book

MEAP VERSION 8 About this MEAP Welcome Brief Table of Contents 1


What is functional programming? 2 Getting started with functional
programming in Scala 3 Functional data structures 4 Handling errors without
exceptions 5 Strictness and laziness 6 Purely functional state 7 Purely
functional parallelism 8 Property-based testing 9 Parser combinators 10
Monoids 11 Monads 12 Applicative and traversable functors 13 External
effects and I/O 14 Local effects and mutable state 15 Stream processing and
incremental I/O
1 What is functional programming?
In this chapter
Understanding the benefits of functional programming
Defining pure functions
Referential transparency, purity, and the substitution model

Functional programming (FP) is based on a simple premise with far-reaching


implications: we construct our programs using only pure functions — in other
words, functions that have no side effects. What are side effects? A function
has a side effect if it does something other than simply return a result, for
example:

Modifying a variable
Modifying a data structure in place
Setting a field on an object
Throwing an exception or halting with an error
Printing to the console or reading user input
Reading from or writing to a file
Drawing on the screen

We’ll provide a more precise definition of side effects later in this chapter,
but consider what programming would be like without the ability to do these
things, or with significant restrictions on when and how these actions can
occur. It may be difficult to imagine. How is it even possible to write useful
programs at all? If we can’t reassign variables, how do we write simple
programs like loops? What about working with data that changes, or handling
errors without throwing exceptions? How can we write programs that must
perform I/O, like drawing to the screen or reading from a file?

The answer is that functional programming is a restriction on how we write


programs, but not on what programs we can express. Over the course of this
book, we’ll learn how to express all of our programs without side effects, and
that includes programs that perform I/O, handle errors, and modify data.
We’ll learn how following the discipline of FP is tremendously beneficial
because of the increase in modularity that we gain from programming with
pure functions. Because of their modularity and lack of side effects, pure
functions are easier to test, reuse, parallelize, generalize, and reason about.
Furthermore, pure functions are much less prone to bugs.

In this chapter, we’ll look at a simple program with side effects and
demonstrate some of the benefits of FP by removing these side effects. We’ll
also discuss the benefits of FP more generally and define two important
concepts—referential transparency and the substitution model.

1.1 Understanding the benefits of functional


programming
Let’s look at an example that demonstrates some of the benefits of
programming with pure functions. The point here is just to illustrate some
basic ideas that we’ll return to throughout this book. This will also be your
first exposure to Scala’s syntax. We’ll talk through Scala’s syntax much more
in the next chapter, so don’t worry too much about following every detail. As
long as you have a basic idea of what the code is doing, that’s what’s
important.

1.1.1 A program with side effects

Suppose we’re implementing a program to handle purchases at a coffee shop.


We’ll begin with a Scala 3[1] program that uses side effects in its
implementation (also called an impure program). Don’t worry too much
about Scala syntax at this point—we’ll take a closer look at that in the next
chapter.

Listing 1.1. A Scala program with side effects

class Cafe: #1
def buyCoffee(cc: CreditCard): Coffee = #2
val cup = Coffee() #3
cc.charge(cup.price) #4
cup #5
class CreditCard: #6
def charge(price: Double): Unit = #7
println("charging " + price) #8

class Coffee:
val price: Double = 2.0

val cc = CreditCard() #9
val cafe = Cafe()
val cup = cafe.buyCoffee(cc)

The line cc.charge(cup.price) is an example of a side effect. Charging a


credit card involves some interaction with the outside world—suppose it
requires contacting the credit card company via some web service,
authorizing the transaction, charging the card, and (if successful) persisting
some record of the transaction for later reference. But our function merely
returns a Coffee and these other actions are happening on the side, hence the
term “side effect.” (Again, we’ll define side effects more formally later in this
chapter.)

As a result of this side effect, the code is difficult to test. We don’t want our
tests to actually contact the credit card company and charge the card! This
lack of testability is suggesting a design change: arguably, CreditCard
shouldn’t have any knowledge baked into it about how to contact the credit
card company to actually execute a charge, nor should it have knowledge of
how to persist a record of this charge in our internal systems. We can make
the code more modular and testable by letting CreditCard be ignorant of
these concerns and passing a Payments object into buyCoffee.

Listing 1.2. Adding a payments object

class Cafe:
def buyCoffee(cc: CreditCard, p: Payments): Coffee =
val cup = Coffee()
p.charge(cc, cup.price)
cup

class CreditCard #1

trait Payments: #2
def charge(cc: CreditCard, price: Double): Unit #3
class SimulatedPayments extends Payments: #4
def charge(cc: CreditCard, price: Double): Unit =
println("charging " + price + " to " + cc)

class Coffee:
val price: Double = 2.0

val cc = CreditCard()
val p = Payments()
val cafe = Cafe()
val cup = cafe.buyCoffee(cc, p)

We’ve extracted the charging logic in to the Payments interface—in essence,


employing dependency injection. Though side effects still occur when we call
p.charge(cc, cup.price), we have at least regained some testability. We
can write a stub implementation of the Payments interface that is suitable for
testing. But that isn’t ideal either. We’re forced to make Payments an
interface, when a concrete class may have been fine otherwise, and any stub
implementation will be awkward to use. For example, it might contain some
internal state tracking the charges that have been made. We’ll have to inspect
that state after the call to buyCoffee, and our test will have to make sure this
state has been appropriately modified (mutated) by the call to charge. We
can use a mock framework or similar to handle this detail for us, but this all
feels like overkill if we just want to test that buyCoffee creates a charge equal
to the price of a cup of coffee.[3]

Separate from the concern of testing, there’s another problem: it’s difficult to
reuse buyCoffee. Suppose a customer, Alice, would like to order 12 cups of
coffee. Ideally we could just reuse buyCoffee for this, perhaps calling it 12
times in a loop. But as it is currently implemented, that will involve
contacting the payment system 12 times, authorizing 12 separate charges to
Alice’s credit card! That adds more processing fees and isn’t good for Alice
or the coffee shop.

What can we do about this? We could write a whole new function,


buyCoffees, with special logic for batching up the charges.[4] Here, that
might not be such a big deal, since the logic of buyCoffee is so simple, but in
other cases the logic we need to duplicate may be nontrivial, and we should
mourn the loss of code reuse and composition!
1.1.2 A functional solution: removing the side effects

The functional solution is to eliminate side effects and have buyCoffee return
the charge as a value in addition to returning the Coffee. The concerns of
processing the charge by sending it off to the credit card company, persisting
a record of it, and so on, will be handled elsewhere. Again, we’ll cover
Scala’s syntax more in later chapters, but here’s what a functional solution
might look like:
class Cafe:
def buyCoffee(cc: CreditCard): (Coffee, Charge) = #1
val cup = new Coffee()
(cup, Charge(cc, cup.price)) #2

Here we’ve separated the concern of creating a charge from the processing or
interpretation of that charge. The buyCoffee function now returns a Charge
as a value along with the Coffee. We’ll see shortly how this lets us reuse it
more easily to purchase multiple coffees with a single transaction. But what
is Charge? It’s a data type we just invented containing a CreditCard and an
amount, equipped with a handy function, combine, for combining charges
with the same CreditCard:
case class Charge(cc: CreditCard, amount: Double): #1
def combine(other: Charge): Charge =
if cc == other.cc then #2
Charge(cc, amount + other.amount) #3
else
throw new Exception("Can't combine charges with different cards") #4

Figure 1.1. A call to buy coffee.


Now let’s look at buyCoffees, to implement the purchase of n cups of coffee.
Unlike before, this can now be implemented in terms of buyCoffee, as we
had hoped. Note there’s a lot of new syntax and methods in this
implementation, which we’ll gradually become familiar with over the next
few chapters.

Listing 1.3. Buying multiple cups with buyCoffees

class Cafe:

def buyCoffee(cc: CreditCard): (Coffee, Charge) = ...

def buyCoffees(cc: CreditCard, n: Int): (List[Coffee], Charge) = #1


val purchases: List[(Coffee, Charge)] = List.fill(n)(buyCoffee(cc)) #2
val (coffees, charges) = purchases.unzip #3
(coffees, charges.reduce((c1, c2) => c1.combine(c2))) #4

Overall, this solution is a marked improvement—we’re now able to reuse


buyCoffee directly to define the buyCoffees function, and both functions are
trivially testable without having to define complicated stub implementations
of some Payments interface. In fact, the Cafe is now completely ignorant of
how the Charge values will be processed. We can still have a Payments class
for actually processing charges, of course, but Cafe doesn’t need to know
about it.

Making Charge into a first-class value has other benefits we might not have
anticipated: we can more easily assemble business logic for working with
these charges. For instance, Alice may bring her laptop to the coffee shop and
work there for a few hours, making occasional purchases. It might be nice if
the coffee shop could combine these purchases Alice makes into a single
charge, again saving on credit card processing fees. Since Charge is first-
class, we can write the following function to coalesce any same-card charges
in a List[Charge]:
def coalesce(charges: List[Charge]): List[Charge] =
charges.groupBy(_.cc).values.map(_.reduce(_.combine(_))).toList

We’re passing functions as values to the groupBy, map, and reduce methods.
You’ll learn to read and write one-liners like this over the next several
chapters. The _.cc and _.combine(_) are syntax for anonymous functions,
which we’ll introduce in the next chapter. As a preview, _.cc is equivalent to
c => c.cc and _.combine(_) is equivalent to (c1, c2) =>
c1.combine(c2).

You may find this kind of code difficult to read because the notation is very
compact. But as you work through this book, reading and writing Scala code
like this will become second nature to you very quickly. This function takes a
list of charges, groups them by the credit card used, and then combines them
into a single charge per card. It’s perfectly reusable and testable without any
additional mock objects or interfaces. Imagine trying to implement the same
logic with our first implementation of buyCoffee!

This is just a taste of why functional programming has the benefits claimed,
and this example is intentionally simple. If the series of refactorings used
here seems natural, obvious, unremarkable, or standard practice, that’s good.
FP is merely a discipline that takes what many consider a good idea to its
logical endpoint, applying the discipline even in situations where its
applicability is less obvious. As you’ll learn over the course of this book, the
consequences of consistently following the discipline of FP are profound and
the benefits enormous. FP is a truly radical shift in how programs are
organized at every level—from the simplest of loops to high-level program
architecture. The style that emerges is quite different, but it’s a beautiful and
cohesive approach to programming that we hope you come to appreciate.

What about the real world?

We saw in the case of buyCoffee how we could separate the creation of the
Charge from the interpretation or processing of that Charge. In general, we’ll
learn how this sort of transformation can be applied to any function with side
effects to push these effects to the outer layers of the program. Functional
programmers often speak of implementing programs with a pure core
and a thin layer on the outside that handles effects.

But even so, surely at some point we must actually have an effect on the
world and submit the Charge for processing by some external system. And
aren’t there other useful programs that necessitate side effects or mutation?
How do we write such programs? As we work through this book, we’ll
Another Random Document on
Scribd Without Any Related Topics
The Project Gutenberg eBook of Lily's
birthday
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Lily's birthday

Author: Madeline Leslie

Release date: May 20, 2024 [eBook #73659]

Language: English

Original publication: Boston: Graves & Young, 1867

*** START OF THE PROJECT GUTENBERG EBOOK LILY'S BIRTHDAY


***
Transcriber's note: Unusual and inconsistent spelling is
as printed.

AUNT HATTIE'S LIBRARY


Lily's Birthday.

BY

AUNT HATTIE

[MADELINE LESLIE]

AUTHOR OF THE "BROOKSIDE SERIES," ETC.

"Be kindly affectioned one to another."—PAUL

BOSTON:

PUBLISHED BY GRAVES & YOUNG

24 CORNHILL.
Entered, according to Act of Congress, in the year 1867, by

REV. A. R. BAKER,

In the Clerk's Office of the District Court for the District of


Massachusetts.

ROCKWELL & ROLLINS, STEREOTYPERS,


122 Washington Street.

To

NELLIE, ROLAND COTTON, ANNIE, AND FULLER


APPLETON,

CHILDREN OF MY BELOVED NEPHEW,

THE REV. JOHN COTTON SMITH, D.D.,

THESE SMALL VOLUMES ARE AFFECTIONATELY INSCRIBED,

WITH THE EARNEST PRAYER

THAT THEIR LIVES MAY PROVE THEM TO BE LAMBS IN THE FOLD

OF THE GREAT AND GOOD

Shepherd of Israel.
CONTENTS.

CHAPTER I. THE BIRTHDAY

CHAPTER II. LILY'S CITY HOME

CHAPTER III. THE TEA-PARTY

CHAPTER IV. MAMMA'S DRIVE

CHAPTER V. LILY'S COUSIN STUART

CHAPTER VI. COUSIN STUART'S STORY

CHAPTER VII. BILLY'S CLEAN FACE

CHAPTER VIII. THE AUGUST TREE

LILY'S BIRTHDAY.

CHAPTER I.
THE BIRTHDAY.

IT was cold weather; but the day was bright and


beautiful. Baby Lily in her warm bed rubbed her eyes, and
tried to wake herself up. She knew something pleasant was
going to happen; but for a minute or two she couldn't
recollect what it was, and lay digging into her sleepy eyes
with her tiny, dimpled hand, when a soft voice across the
chamber, whispered—

"Baby Lily! Baby Lily! Wake up! Wake up! It's your
birthday!"

"Oh, yes, Helen!" cried the child, starting up. "So it is!"

Helen rose from her couch and, walking softly across


the chamber, kissed her sister four times.

"Aren't you glad, you little darling, that the day has
come; and wont we have a splendid time at your birthday
party?"

Baby Lily's eyes sparkled,—I wish you could have seen


them,—and her cheeks grew such a pretty pink, you would
have thought the roses had been kissing them. It was still
very early; but Lily was impatient for the pleasures of the
day to begin; so she slipped down the side of the bed,
saying,—

"Sarah! Sarah! Can't I go downstairs? I want to. Oh, I'm


so glad my birthday has come!"

"I'm afraid you'll wake baby brother, pet."


"Oh," exclaimed Helen, "I heard him cooing long ago."

So Sarah reached from the chair at the side of the bed a


pair of stockings, and oh, such tiny shoes! And, having
arrayed her little charge in them, sent her down to the
nursery to be dressed, while she herself took another nap.

Helen caught up her clothes and pattered down after


her sister. I suppose if you had caught a glimpse of Helen in
her long white nightdress, and her curls floating like a veil
about her, you would have thought her smiles were on
account of the expected party; but they were not. They
were always there. Indeed, I can't imagine how her mouth
would have looked without smiles. It was just like a fresh
sunbeam to see her come dancing into the room.

The nursery was very warm and pleasant, for there was
a bright fire crackling and blazing away in the grate, as if it
knew that this was a birthday, and meant to help celebrate
it.

Margery sat in a low chair before the fire with Master


Berty, a stout urchin of six months, springing and jumping
in her arms.

Both Helen and Lily made their first addresses to the


family pet, who cooed out his welcome in the very sweetest
tones you ever heard. Certainly his little sisters thought no
music was ever half so sweet. And there they stood bowing
and catchooing, and laughing, while baby, every time Helen
came near enough, would make a dive at her curls. It would
have done you good to have seen them.

All this while Margery was laughing and enjoying the


fun; but now, she tried to hurry them with their dressing.
"Come, Miss Helen," she urged, "if you play with baby
any longer, you'll never be in season for breakfast. Baby
Lily, bring me your skirt, and let me fasten it."

In one minute there was a dreadful scream. Margery


tried to button the waist with her arm around the baby,
when he gave a sudden spring, and over he went on to the
rug, making a dreadful bump on his forehead, and cheek.

Poor Margery had scarcely time to catch him up before


mamma rushed from the chamber adjoining, and grandma
from her room, frightened almost out of their senses, for
fear he had fallen into the fire.

Baby cried dreadfully, and held his breath; and all the
while the bump was growing larger and more red, until at
last he was so tired he was glad to lay his poor aching head
on his mamma's shoulder to rest. But even here, he
couldn't forget, and turned his red, swollen eyes from one
to another, with such an expression, that they pitied him
very, very much.

Little Lily forgot that it was her birthday, and her eyes
were full of tears; and her lip quivered so that she could
scarcely speak.

Surely I don't know who dressed the children, for


everybody was so confused by the sad accident, and so
sorry for Master Berty, that they could think of nothing else;
so the sun went on rising higher and higher, until he could
peep into the nursery windows; and then Helen laughed
softly as she said,—

"O Lily! Aren't you glad it's going to be a pleasant day?"

In a few minutes the room was all quiet; for mamma,


who was still weak from her recent illness, had gone back to
bed, and papa was trying to obey the doctor's directions,
and get all the rest he could. The children were very happy
when baby so far forgot his trouble that he could play
again. Helen let him pull her curls, exclaiming, "So you
shall, darling; you shall pull Helen as much as you want to."

He had just got his little fingers nicely tangled in the


closely curling locks, and was cooing out his delight, when
there was another surprise; but this time it was a pleasant
one, for the door softly opened, and there stood Aunt Hatty.

Helen flew to meet her, followed by Russell, who asked,


"Where's Frankie,—hasn't he come?"

And then Frankie, who had been hiding behind the door,
burst in, and was as warmly welcomed as his mother had
been.

The new comers had been travelling all night, and were
very tired; but they dearly loved these friends, and they
were both glad that they had come in season for the
birthday party.

CHAPTER II.

LILY'S CITY HOME.


BEFORE I go on to relate what happened on that
pleasant day, I must tell you some things about baby Lily
and her home.

She did not always live in the city, though her father
was Rector of a large and wealthy parish there. In the
summer they went a long way into the country, down near
the sea-side, where the children could fill their lungs with
nice, fresh air, and where the father and mother could gain
new strength for the performance of their arduous duties.
Some time I may tell you of the delights of their country
home; but now I will say that the parsonage or rectory was
a large, commodious mansion, joined to the rear end of the
church.

The channel, the pulpit, and the reading desk were in a


deep, wide recess. There were quaint, old-fashioned rooms
in the house, formed out of the space at the side of the
chancel. One of these rooms on the lower floor, the pastor
occupied for his study. It had a high Gothic window, with
small, diamond panes of glass; and the walls were wholly
lined with cases containing books. There were large,
elegantly bound volumes on the lower shelves; then on the
others, the books were smaller and smaller to the very top
shelf, which could only be reached by a pair of high steps.

There was one large bust, too, which the children often
gazed at, because it looked so peaceful and smiling. This
was a bust of their great grandfather, an eminent divine,
and teacher of theology.

But I cannot stop to tell you all the wonders of the


study, nor to describe the Rector, who sat long hours at the
table in the centre of the room, poring over the old-
fashioned volumes, and writing the sermons which he
prayed God might help to fit his beloved people for heaven.
I must go on to tell you about the chamber over the study,
which was called the church-room. This was lighted by a
continuation of the same window with its funny little panes
of glass, through which the sunlight streamed in so
gloriously.

The room in the third story over this was devoted to the
children, for their toys; and well it was filled with all sorts,
from tin horses harnessed in pedlers' carts, to the family of
Noah just walking out of the ark.

Besides the pastor and his wife, there belonged to the


family four children,—Helen, Russell, Lily, and baby Herbert.

There had been another loved one, the first-born, the


dearest treasure known on earth.

"Lovely as an angel's dream,


Her chestnut locks with sunlight all agleam,
Her holy eyes with heaven in their beam."

* * * * * *

"But when the elder Shepherd of the fold


Came, covered with the storm, and pale and cold,
And begged for one of the sweet lambs to hold,
The parents knelt to pray! Is it thy will?
Ah, how they wept at the last word 'farewell!'"

As I told you in the first chapter, the birthday dawned


clear and bright. The children had scarcely finished their
breakfast when there was a ring at the door; and who
should it be, but Miss Norton; with a box for baby Lily.
This little girl now began to realize that birthdays were
delightful. Her violet eyes opened wider and wider as Sarah
untied the box, and took from it a beautiful plated tea-set,
shining like silver.

"Oh," exclaimed Russell, "wont we have nice times


now? Mamma, can't we have our tea-party right away?"

Mamma smiled. "Yes, darling," she said, "as soon as


Margery has cleared the room."

At this moment Sarah came in, bringing baby brother


fresh from his bath, and all the children forgot their play in
their eagerness to get a kiss. Baby jumped, and cooed, and
laughed such funny little laughs, drawing in his breath, and
then stopping to catch Helen's curls, as she pressed closer
to him.

"Come, Frankie," cried Russell at last, "let's go and set


the table now."

"I think real, live babies are better than all the tea-
parties in the world," answered Frank, warmly. "Oh, I love
to hear them laugh!"

There was a low table in the nursery, on which the little


folks used to take their supper before they were old enough
to dine with papa and mamma. This was now covered with
wooden horses and sheep; and Frankie helped to pack the
animals away in the box where they belonged.

"Please, Sarah," asked Russell, "may we have a table-


cover?"

"Certainly, dear," and she gave him one from the


drawer.
Before the cups and saucers and plates were arranged
in order on the pretty tray, there was another ring, followed
by the sound of merry voices in the hall.

"It's Aunt Mary!" was the joyful shout. "It's Aunt Mary,
with Ida and Rose."

"Yes, it is," repeated Russell, running to the window,


"and there's Pat bringing a great bundle from the carriage."

The door opened, and there stood Aunt Mary with her
arms full of parcels, and behind her, Ida and Rose, looking
as smiling as the month of June.

"Look, look, see Lily's new tea-set!"

But Aunt Mary could see nothing till she had laid the
bundles carefully on the table. Then she stooped to give
baby a kiss; after which, she was ready to attend to the
children.

CHAPTER III.

THE TEA-PARTY.

"PUT the waiter that side," said Sarah. "Lily must sit
there, and pour out the tea, because it's her birthday."

Russell was watching the untying of the parcels Aunt


Mary had brought, and clapped his hands when he saw the
nice light cakes and the cream-colored candy.

Sarah well understood how to prevent unkindness


between the children, and so she superintended the
distribution of the feast, while the little girl sat in state
behind the tiny tray, mixing sugar, cream, and water in the
pretty cups.

At last every one was served; and then what pleasant


talk, what shouts of mirth, what merry peals of laughter
echoed through the room! Mamma, grandma, Aunt Mary,
and Aunt Hatty laughed, and enjoyed the feast almost as
well as the children did. Mammas always do enjoy their
children's sports, when the little ones are generous, kind,
and loving, as these children were.

I wish I were an artist, and could paint the scene as it


occurred. I think you would say, as Aunt Hatty did, that
there never were brighter, happier faces than surrounded
that little table; and there never were friends more
sympathizing than those who witnessed the joy of the
merry party.

"Sarah," called out Russell at last, "Rose has eaten all


her cake. May I give her some of mine?"

"There is plenty more. Why don't you eat your own?


Here, Rose, pass me your plate. Helen, what are you and
Ida laughing about? Don't you want another piece of cake,
Lily?"

Every plate was held up now to be refilled; and then


baby Lily had as much as she could do to pour coffee, as
she called it, for all her guests. She looked very serious as
she set about her task, putting in a little more sugar, a little
more milk; then stirring and tasting, to be sure it was right;
while Helen and Ida, as the oldest of the company, tried
hard to look sober, too, so as not to confuse the anxious
miss.

"Hurrah! We've done!" shouted Russell, rising and


clapping his hands. "Now let's have some fun!"

"Oh, look at baby?" exclaimed Helen. "See how he


wants to play, too. Oh, I wish he had sat at the table with
us!"

"I rather think he would have wanted all the cups," said
mamma, smiling. "You know he has never been into society,
and would not understand how to conduct with propriety at
dinner-parties."

"Isn't he a darling?" asked Helen, as baby shouted, and


cooed his delight at having her near him.

"I think babies are splendid," rejoined Frankie, coming


forward for a share of notice from the pet.

"They are household angels," murmured Aunt Hatty,


softly.

Presently there was a great shout of laughter, in the


midst of which Russell walked into the room, bowing. "This
is the bride of the church," he said, introducing his sister,
whom he had arrayed in a long, white skirt. "I hope you will
excuse the black on her dress, because her husband has
just died."

Baby Lily walked forward with great dignity, bowing and


smiling, while her brother, who had once more disappeared,
soon returned, and made every one shout again, as he
promenaded the room dressed in a black gown, and gave
out notice of a service in the church in the evening.
At last the door-bell rung, and Pat sent up word that the
carriage was ready to take Aunt Mary and the children
home.

"How quick the morning has gone!" exclaimed Ida. "I


thought we should have a good deal longer to stay."

"So I did," said Rose, shaking back her heavy curls, and
getting ready to go.

Aunt Mary hurried to array her young charge for the


ride, Helen and Frank helping to find hats, furs, and gloves.

Lily, as directed by mamma, sent her thanks to Aunt


Josephine for letting her cousins come, and for the present
of cake, and then the good-by kisses were given, Russell
shouting after them as they went downstairs,—

"Haven't we had nice fun?"

"And not one word of unkindness or quarrelling. That is


the reason you have all enjoyed yourselves so thoroughly,"
suggested Aunt Hatty, kissing the merry boy.

CHAPTER IV.

MAMMA'S DRIVE.

IN the afternoon, just as mamma had finished her


dinner, a beautiful carriage with two prancing horses drove
up to the door. A lady had called to take her out for a drive
in the park.

Mamma hesitated. She was timid about riding; and then


it was Lily's birthday, and there were so many little ones in
the nursery.

But papa came from the study, and ended the matter by
saying,—

"You must go, my dear. The bracing air will do you


good."

While she was absent, the children had various games.


Sometimes they dressed up, and played they were visitors
from the country. Helen was the lady of the house, and
Frank and Russell made her a call; while Lily sat in a low
chair, and rocked her dolly; and then they brought in the
rocking-horse, and played go a journey.

By and by they grew tired, and were contented to sit


quietly on the sofa, while Aunt Hatty told them a story. She
had only just finished, when mamma returned, not
refreshed, but pale and weary.

"What has happened?" asked Sarah, eagerly.

"Such a scene as I have witnessed!" exclaimed mamma,


falling back in a chair quite exhausted. "I was so glad I
didn't take Lily."

"Please, mamma, tell us about it," asked Helen.

"In the first place," began mamma, "Mrs. Groves'


horses were perfectly furious, and would not allow anything
to pass them. I grew very nervous, when all at once there
was a crashing of wheels; and there we were locked in with
a great team.

"I imagined Mrs. Groves wished herself anywhere but


riding with a nervous woman, and I'm sure I was sorry that
I had consented to go. We backed, and the teamster
backed, ha'ing and geeing lustily, and at last we were
relieved.

"Now, I thought, we shall have a clear space; and I'll try


to be brave. But presently we heard a great outcry and
shouting behind us.

"'Stop them! Oh, stop them!'

"I looked from the window, and saw everybody running;


then they all began to press to the sides of the street, and
drivers urged their horses forward at their utmost speed.

"'What is it, James?' screamed Mrs. Groves through the


speaking-trumpet.

"'It is horses running away, ma'am,' he answered back.

"'Stop, then; and we'll get out.'

"'You'd be smashed entirely, ma'am, in the crowd.'

"Just at this moment, and when I was trembling all


over, a pair of magnificent horses dashed past, in an open
barouche; and there, standing in it, with her hands
stretched out in supplication, was a dear little girl just about
as old as Lily. As they rushed past, I heard her say,—

"'Oh, do stop them! Do please stop them!'


"I couldn't help it; I just put my handkerchief to my
face, and had a good cry."

"Did the little girl pray to God to make the horses stop
running?" faltered Lily, her lip quivering as she winked back
her tears.

"I don't know, darling, but she looked like a child who
had been taught to pray."

"I would pray for her, mamma, I would."

"My love, I did pray that the good God might spare her
life; and I thanked him that my own darlings were not in
such danger."

"Was she killed then?" asked Helen, her eyes growing


very large.

"No, dear. Mrs. Groves told James to drive on as fast as


he could. I forgot all about my own fright, in my anxiety to
find out whether the poor little child was saved."

"Why didn't somebody stop the horses, mamma?"

"They did try again and again, Helen; but with no


success. Presently another carriage dashed by, the driver
whipping the horse to his utmost speed. I saw a poor man
leaning back on the seat, looking very pale, while the blood
was oozing from a wound on his head. The crowd screamed
out that it was the father of the little girl who had been
thrown from the barouche. A gentleman picked him up and
wanted to do something for him; but he only pointed up the
street, and gasped out,—

"'My child!'"
Poor Lily could keep back her tears no longer, and laying
her head in Sarah's lap began to sob.

"Lily," said her mamma, "look up, and hear me finish


the story.

"We followed the other carriages until we came to a


great crowd of policemen, who were standing about the
barouche. The brave little girl had been taken out as soon
as the horses were stopped, and there she was in her
father's arms. Oh, how he strained her to his breast, as he
said,—

"'Thank God! She is spared to me!'"

"Did his head bleed then, mamma?"

"Yes, Helen; but he did not seem to think of himself at


all. Tears were running down the cheeks of many who stood
by."

"How did they get home, mamma?"

"The gentleman who picked up the father offered to


take them to their house, and the policemen took care of
the horses till the driver came up."

"I guess the little girl will say a good many prayers to
God to-night," exclaimed Lily, looking up with a brightening
face.

CHAPTER V.
LILY'S COUSIN STUART.

A FEW DAYS after this, dear little Lily came to dinner


with two bright red spots on her cheeks. She did not seem
inclined to talk as usual; but sat very quiet, waiting for
Maria to pass her plate. With the dessert there was some
pineapple, and this Lily thought very nice. I suppose she
must have eaten too much, for in an hour or two she grew
quite sick, and lay on the sofa, her poor head being very
hot and throbbing with pain.

Mamma had gone out to see a sick friend, and Sarah


was herself ill in bed; but Aunt Hatty took the dear child in
her arms, and tried to soothe her to sleep. She lay very
quiet for a time, listening to the lullaby, and Aunt Hatty
thought her asleep; but presently she opened her eyes with
a pleasant smile, saying,—

"Don't go away! I want you to stay here two-free


weeks."

This was the commencement of a long sickness. When


the doctor came the next morning, he said Lily had the
scarlet fever.

During all the days and nights the little sufferer was in
bed, she was very patient; but her feeble moans, as she lay
half unconscious, made mamma's heart ache sadly.

When Lily was better, Helen was taken down with a


similar attack.

On the whole, it was a trying winter for the family,


though from the parish they received a vast amount of
sympathy and kindness.

There was one circumstance which was regarded by all


as a blessing. This was that dear Cousin Stuart, who had
been absent for many years, had returned, and was now
settled in business near them.

Stuart was fond of all children, but particularly so of


these dear ones. Scarcely a day passed without a call upon
his favorites. When his step was heard on the stairs, or his
voice speaking to papa in the hall, there was an immediate
rush from the nursery and a scream of delight to welcome
him.

Even baby Herbert crowed out his pleasure, holding out


his dimpled arms to be taken. Indeed, he would willingly
stay with no one else while his Cousin Stuart was in sight.

It was amusing to witness the scrambling for places


when he took a seat. Helen and Lily were in his lap, Russell
leaning on his knee, while Ida and Rose, who were often
present, crowded as closely as possible, each clamoring to
be heard.

"Please tell us a story."

"We're all ready, Cousin Stuart."

"Please have something funny," said Russell, his eyes


twinkling.

Stuart had some funny stories, which he told once in a


while; and some funny songs, which he sang; but he loved
best to tell of good children in the Bible,—of Joseph, and
Samuel, and Ruth, and Esther,—but more than all of the
child Jesus, who never had committed a sin.

In all his travels, Stuart sought out children, and tried


to do them good. He used to visit Sabbath schools, and
when the boys and girls were through with their lessons, he
would tell them of the Saviour's love; and urge them to
choose him for their Friend.

Perhaps you would like to hear one of Stuart's stories.


Well, I will tell you one.

It was a stormy evening during Easter; but the bright


fire made the nursery look very pleasant. Margery sat near
the grate, with Berty sound asleep on her knees; but
Margery liked to hear stories as well as the children; so she
sat there very still, with one of baby's feet in her hand.

Just opposite nurse, the lounge was drawn up, and


there was Stuart with Lily snuggled down against his breast.
Helen sat holding her cousin's hand, her curls floating over
his shoulder, while her face was all smiles and expectation.
Russell occupied a stool pushed up to Stuart's feet, so that
one arm rested lovingly on his cousin's knee.

In the corner close by baby, Grandma Rawson sat in the


easy-chair, her pale face, framed in beautiful white curls,
looking very sweet and smiling.

Mamma was passing by the door, and stopped to view


the pleasant scene within the room. She watched the dear
children with their eyes fixed so eagerly on Stuart's face,
and a keen pang of sorrow shot for one moment through
her heart as she missed one precious lamb from the fold.

"How Stuart would have loved her!" she murmured, and


with a sigh she passed on.

CHAPTER VI.

COUSIN STUART'S STORY.


"RUSSELL," Stuart began, "do you remember telling
Sarah yesterday morning that you didn't want your face
washed,—it was no use? I'm going to tell you a true story
about a boy who had his face washed, and what happened
in consequence.

"Early last fall, on Sabbath morning, one of the teachers


of our mission school was walking to St. Mary's Church,
when she met a poor boy, who was rubbing his fist into his
eyes. He had been crying, and rubbing his tears with his
dirty hand had made his face look very badly indeed. But
the lady, whose name was Allen, pitied him, and so she
resolved to try and make him feel better.

"'Good morning, young friend,' she said, cheerfully. 'Are


you taking a walk?'

"He looked at her, but did not answer.

"She held out her hand, smiling. 'Will you come with me
to Sunday school?' she asked.

"Billy thought she looked very pleasant, so he nodded


his assent, and they walked along. By and by they arrived
at St. Mary's. Behind the church is a room for the mission
school; and there Miss Allen led her young charge. I don't
think you can guess what was the first lesson she gave
him."

"About Adam and Eve in the garden," said Helen.

"No, 'bout God making the monkeys," exclaimed


Russell.

"I guess she told him about the little baby in the
manger," lisped Lily.
"No, none of these. She took him into a bath-room,
where there were bowls with water flowing into them, and
plenty of soap and clean towels at hand. There was a
woman here, with her bonnet off, her sleeves rolled up to
her elbows, and a wide apron buttoned over her dress.

"She had just finished scrubbing one little fellow, and


was waiting for another, as Miss Allen came in.

"'Oh, dear!' she exclaimed, as she saw Billy's face. 'Oh,


what a sight!'

"She laughed as she took down from a nail a small


mirror, and held it before the wondering boy.

"'Look sharp!' she exclaimed, good-humoredly, 'or you


wont know yourself next time.' Then she turned to Miss
Allen and said, 'There's one more jacket; shall I put it on
him?'

"'Yes, and then send him to my class.'

"Poor Billy stood ready to cry as she left; but he had


other things to attend to, for the woman turned a faucet,
and the hot water began to pour into the boat-shaped tub;
then, from another faucet, cold water, until by thrusting in
her finger she found it was just right.

"Before he knew what she was about, Billy found


himself stripped of his soiled, ragged clothes, and seated in
the bath.

"Then began the scrubbing. It was evident Mrs. Varney


was used to the business, and didn't mind a little spitting
and spluttering when the soap got into the eyes and mouth.
She rubbed on the soap wherever there was need of it, and
then scrubbed with a vengeance.
"When his head and face and neck and ears were
finished, Billy began to like it. It was a new and delightful
feeling to sit there, and have the tepid water all around
him. He thought Sunday school a tip-top thing, and
wondered he had not heard of it before.

"Mrs. Varney generally talked all the time she was at


work. You may be sure, she exclaimed a good deal when
she saw a great red ridge across Billy's shoulders, and again
when she saw his black feet.

"'Say, Billy,' she cried, 'were you ever washed in your


life?'

"'No,' was the meek reply. 'I never know'd how good it
felt; and then we don't have these things,' touching the tub,
'where I live.'

"By and by the boy was on his feet again, his face
shining, and as clean as soap and water could make it. His
eyes had done smarting long before this, and twinkled like
two stars. His hair, which had been in one solid mat of
tangled curls, was nicely combed, and lay, not smooth
indeed, but in fine ringlets all over his head.

"Mrs. Varney was much pleased, and she stooped down


and gave him a hearty kiss.

"'There, Billy,' she exclaimed, in a triumphant tone,


again holding the mirror before him, 'look there, and tell me
who that is, if you can; I guess you never see that boy
afore.'

"Billy's eyes opened wider and wider. He looked at the


clean white face and sparkling orbs with delight; but he did
not feel at all acquainted with those features. Then he
gazed down on his new jacket and laughed.

You might also like