100% found this document useful (3 votes)
1K views

Functional Programming in Scala, Second Edition (MEAP V08) Michael Pilquist All Chapters Instant Download

Michael

Uploaded by

malisemutari
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
100% found this document useful (3 votes)
1K views

Functional Programming in Scala, Second Edition (MEAP V08) Michael Pilquist All Chapters Instant Download

Michael

Uploaded by

malisemutari
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/ 27

Get ebook downloads in full at 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 BUTTON

DOWNLOAD NOW

Explore and download more ebook 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
Other documents randomly have
different content
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.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning of
this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1 with
active links or immediate access to the full terms of the Project
Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or expense
to the user, provide a copy, a means of exporting a copy, or a means
of obtaining a copy upon request, of the work in its original “Plain
Vanilla ASCII” or other form. Any alternate format must include the
full Project Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in paragraph
1.F.3, the Project Gutenberg Literary Archive Foundation, the owner
of the Project Gutenberg™ trademark, and any other party
distributing a Project Gutenberg™ electronic work under this
agreement, disclaim all liability to you for damages, costs and
expenses, including legal fees. YOU AGREE THAT YOU HAVE NO
REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF
WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE
PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE
FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving it,
you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or entity
that provided you with the defective work may elect to provide a
replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the
Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and distribution
of Project Gutenberg™ electronic works, harmless from all liability,
costs and expenses, including legal fees, that arise directly or
indirectly from any of the following which you do or cause to occur:
(a) distribution of this or any Project Gutenberg™ work, (b)
alteration, modification, or additions or deletions to any Project
Gutenberg™ work, and (c) any Defect you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many small
donations ($1 to $5,000) are particularly important to maintaining tax
exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

Project Gutenberg™ eBooks are often created from several printed


editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like