没有合适的资源?快使用搜索试试~ 我知道了~
首页Functional Programming in Scala.pdf
Functional Programming in Scala.pdf

Functional Programming in Scala.pdf Scala 的函数式 编程 hope its help
资源详情
资源评论
资源推荐

brief contents
PART 1: INTRODUCTION TO FUNCTIONAL PROGRAMMING
1. What is functional programming?
2. Getting Started
3. Functional data structures
4. Handling errors without exceptions
5. Strictness and laziness
6. Purely functional state
PART 2: FUNCTIONAL DESIGN AND COMBINATOR LIBRARIES
7. Purely functional parallelism
8. Property-based testing
9. Parser combinators
PART 3: FUNCTIONAL DESIGN PATTERNS
10. Monoids
11. Monads
12. Applicative and traversable functors
PART 4: BREAKING THE RULES: EFFECTS AND I/O
13. External effects and I/O
14. Local effects and the ST monad
15. Stream processing and incremental I/O
www.it-ebooks.info

P
This is not a book about Scala. This book introduces the concepts and techniques
of functional programming (FP)—we use Scala as the vehicle, but the lessons
herein can be applied to programming in any language. Our goal is to give you the
foundations to begin writing substantive functional programs and to comfortably
absorb new FP concepts and techniques beyond those covered here. Throughout
the book we rely heavily on programming exercises, carefully chosen and
sequenced to guide you to discover FP for yourself. Expository text is often just
enough to lead you to the next exercise. Do these exercises and you will learn the
material. Read without doing and you will find yourself lost.
A word of caution: no matter how long you've been programming, learning FP
is challenging. Come prepared to be a beginner once again. FP proceeds from a
startling premise—that we construct programs using only pure functions, or
functions that avoid like writing to a database or reading from a file. Inside effects
the first chapter, we will explain exactly what this means. From this single idea and
its logical consequences emerges a very different way of building programs, one
with its own body of techniques and concepts. We start by relearning how to write
the simplest of programs in a functional way. From this foundation we will build
the tower of techniques necessary for expressing functional programs of greater
complexity. Some of these techniques may feel alien or unnatural at first and the
exercises and questions can be difficult, even brain-bending at times. This is
normal. Don't be deterred. Keep a beginner's mind, try to suspend judgment, and if
Preface
P.1 About this book
1
www.it-ebooks.info

you must be skeptical, don't let this skepticism get in the way of learning. When
you start to feel more fluent at expressing functional programs, then take a step
back and evaluate what you think of the FP approach.
This book does not require any prior experience with Scala, but we won't spend
a lot of time and space discussing Scala's syntax and language features. Instead
we'll introduce them as we go, with a minimum of ceremony, mostly using short
examples, and mostly as a consequence of covering other material. These minimal
introductions to Scala should be enough to get you started with the exercises. If
you have further questions about the Scala language while working on the
exercises, you are expected to do some research and experimentation on your own
or follow some of our links to further reading.
The book is organized into four parts, intended to be read sequentially. Part 1
introduces functional programming, explains what it is, why you should care, and
walks through the basic low-level techniques of FP, including how to organize and
structure small functional programs, define functional data structures, and handle
errors functionally. These techniques will be used as the building blocks for all
subsequent parts. Part 2 introduces functional design using a number of worked
examples of functional libraries. It will become clear that these libraries follow
certain patterns, which highlights the need for new cognitive tools for abstracting
and generalizing code—we introduce these tools and explore concepts related to
them in Part 3. Building on Part 3, Part 4 covers techniques and mechanisms for
writing functional programs that perform I/O (like reading/writing to a database,
files, or the screen) or writing to mutable variables.
Though the book can be read sequentially straight through, the material in Part
3 will make the most sense after you have a strong familiarity with the functional
style of programming developed over parts 1 and 2. After Part 2, it may therefore
be a good idea to take a break and try getting more practice writing functional
programs beyond the shorter exercises we work on throughout the chapters. Part 4
also builds heavily on the ideas and techniques of Part 3, so a second break after
Part 3 to get experience with these techniques in larger projects may be a good idea
before moving on. Of course, how you read this book is ultimately up to you, and
you are free to read ahead if you wish.
Most chapters in this book have similar structure. We introduce and explain
some new idea or technique with an example, then work through a number of
exercises, introducing further material via the exercises. The exercises thus serve
P.2 How to read this book
2
www.it-ebooks.info
剩余303页未读,继续阅读















安全验证
文档复制为VIP权益,开通VIP直接复制

评论3