Muutke küpsiste eelistusi

E-raamat: Functional Programming in Scala, Second Edition

  • Formaat: 488 pages
  • Ilmumisaeg: 08-Aug-2023
  • Kirjastus: Manning Publications
  • Keel: eng
  • ISBN-13: 9781638351962
Teised raamatud teemal:
  • Formaat - EPUB+DRM
  • Hind: 51,64 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
  • Formaat: 488 pages
  • Ilmumisaeg: 08-Aug-2023
  • Kirjastus: Manning Publications
  • Keel: eng
  • ISBN-13: 9781638351962
Teised raamatud teemal:

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

Discover the power that functional programming brings to your Scala code. This international bestseller has been revised with new exercises, annotations, and full coverage of Scala 3.

In  Functional Programming in Scala, Second Edition you will learn how to:







Recognize and write purely functional code Work with errors without using exceptions Work with state and concurrency Interact with functional structures that define common behaviors Write code that performs I/O without sacrificing functional programming



The first edition of  Functional Programming in Scala has helped over 30,000 developers discover the power of functional programming. This second edition is fully updated to Scala 3 and the latest standards of FP. Inside, you'll find a serious tutorial for programmers looking to apply functional programming to improve their everyday coding practices. You'll progress from the basics to advanced topics in a logical, concise, and clear progression. Throughout, concrete examples and exercises open up the world of functional programming. about the technology Functional programming (FP) is a style of software development emphasizing functions that don't depend on program state. Functional code is easier to test and reuse, simpler to parallelize, and less prone to bugs than other code. Scala is a popular JVM language that offers strong support for FP. Its familiar syntax and transparent interoperability with Java make Scala a great place to start learning FP. about the book Functional Programming in Scala, Second Edition teaches you functional programming from first principles using the powerful Scala language. You'll develop the unique skills you need to start thinking functionally through hands-on exercises and coding challenges. New to the revised second edition, each exercise comes with extensive annotations to help you understand functional programming in-depth. You'll even learn how to build your own Scala functional library that's perfectly adapted to your needs. You'll soon be writing Scala code that's easier to read, easier to reuse, better for concurrency, and less prone to bugs and errors. RETAIL SELLING POINTS 

Recognize and write purely functional code  Work with errors without using exceptions  Work with state and concurrency  Interact with functional structures that define common behaviours  Write code that performs I/O without sacrificing functional programming 

AUDIENCE  For programmers experienced in Java or Scala. No prior knowledge of functional programming required.
Foreword to the first edition xiv
Foreword to the second edition xvi
Preface to the second edition xviii
Acknowledgments xx
About this book xxii
About the authors xxvii
Part 1 Introduction to functional programming
1(140)
1 What is functional programming?
3(12)
1.1 Understanding the benefits of functional programming
4(6)
A program with side effects
4(3)
Afunctional solution: Removing the side effects
7(3)
1.2 Exactly what is a (pure) function?
10(1)
1.3 Referential transparency, purity, and the substitution model
11(2)
1.4 Conclusion
13(2)
2 Getting started with functional programming in Scala
15(19)
2.1 Introducing Scala the language
16(4)
Running our program
19(1)
2.2 Objects and namespaces
20(1)
2.3 Higher-order functions: Passing functions to functions
21(4)
A short detour: Writing loops functionally
21(3)
Writing our first higher-order function
24(1)
2.4 Polymorphic functions: Abstracting over types
25(2)
An example of a polymorphic function
25(1)
Calling higher-order functions with anonymous functions
26(1)
2.5 Following types to implementations
27(3)
2.6 Conclusion
30(4)
3 Functional data structures
34(33)
3.1 Defining functional data structures
35(3)
3.2 Pattern matching
38(2)
3.3 Data sharing in functional data structures
40(10)
The efficiency of data sharing
42(1)
Recursion over lists and generalizing to higher-order functions
43(4)
More functions for working with lists
47(2)
Loss of efficiency when assembling list functions from simpler components
49(1)
3.4 Trees
50(5)
3.5 Conclusion
55(1)
3.6 Exercise answers
56(11)
4 Handling errors ivithout exceptions
67(27)
4.1 The good and bad aspects of exceptions
68(2)
4.2 Possible alternatives to exceptions
70(1)
4.3 The Option data type
71(10)
Usage patterns for Option
72(4)
Option composition, lifting, and wrapping exception-oriented APIs
76(5)
4.4 The Either data type
81(8)
Accumulating errors
83(2)
Extracting a Validated type
85(4)
4.5 Conclusion
89(1)
4.6 Exercise answers
90(4)
5 Strictness and laziness
94(24)
5.1 Strict and nonstrict functions
95(3)
5.2 Lazy lists: An extended example
98(3)
Memoizing lazy lists and avoiding recomputation
99(1)
Helper functions for inspecting lazy lists
100(1)
5.3 Separating program description from evaluation
101(3)
5.4 Infinite lazy lists and corecursion
104(5)
5.5 Conclusion
109(1)
5.6 Exercise answers
110(8)
6 Purely junctional state
118(23)
6.1 Generating random numbers using side effects
118(2)
6.2 Purely functional random number generation
120(2)
6.3 Making stateful APIs pure
122(2)
6.4 A better API for state actions
124(4)
Combining state actions
125(1)
Nesting state actions
126(2)
6.5 A general state action data type
128(1)
6.6 Purely functional imperative programming
129(3)
6.7 Conclusion
132(1)
6.8 Exercise Answers
133(8)
Part 2 Functional design and combinator libraries
141(112)
7 Purely functional parallelism
143(36)
7.1 Choosing data types and functions
144(8)
A data type for parallel computations
146(2)
Combining parallel computations
148(2)
Explicit forking
150(2)
7.2 Picking a representation
152(6)
Refining the API
154(4)
7.3 The algebra of an API
158(10)
The law of mapping
159(1)
The law of forking
160(1)
Breaking the law: A subtle bug
161(2)
A fully non-blocking Par implementation using actors
163(5)
7.4 Refining combinators to their most general form
168(3)
7.5 Conclusion
171(1)
7.6 Exercise answers
172(7)
8 Property-based testing
179(35)
8.1 A brief tour of property-based testing
180(10)
Choosing data types and functions
182(1)
Initial snippets of an API
183(1)
The meaning and API of properties
184(2)
The meaning and API of generators
186(1)
Generators that depend on generated values
187(1)
Refining the Prop data type
188(2)
8.2 Test case minimization
190(9)
Using the library and improving its usability
192(1)
Some simple examples
192(2)
Writing a test suite for parallel computations
194(5)
8.3 Testing higher-order functions and future directions
199(1)
8.4 The laws of generators
200(1)
8.5 Conclusion
201(1)
8.6 Exercise answers
202(12)
9 Parser combinators
214(39)
9.1 Designing an algebra first
215(5)
9.2 A possible algebra
220(5)
Slicing and nonempty repetition
222(3)
9.3 Handling context sensitivity
225(1)
9.4 Writing a json parser
226(2)
The JSON format
227(1)
A JSON parser
227(1)
9.5 Error reporting
228(5)
A possible design
229(1)
Error nesting
230(2)
Controlling branching and backtracking
232(1)
9.6 Implementing the algebra
233(7)
One possible implementation
234(1)
Sequencing parsers
235(1)
Labeling parsers
236(1)
Failover and backtracking
237(1)
Context-sensitive parsing
238(2)
9.7 Conclusion
240(1)
9.8 Exercise answers
241(12)
Part 3 Common structures in functional design
253(100)
10 Monoids
255(28)
10.1 What is a monoid?
256(2)
10.2 Folding lists with monoids
258(1)
10.3 Associativity and parallelism
259(2)
10.4 Example: Parallel parsing
261(2)
10.5 Typeclasses
263(2)
10.6 Foldable data structures
265(2)
10.7 Composing monoids
267(2)
Assembling more complex monoids
267(2)
Using composed monoids to fuse traversals
269(1)
10.8 Conclusion
269(2)
10.9 Exercise answers
271(12)
11 Monads
283(30)
11.1 Functors: Generalizing the map function
284(3)
Functor laws
285(2)
11.2 Monads: Generalizing the flatMap and unit functions
287(3)
The Monad trait
287(3)
11.3 Monadic combinators
290(1)
11.4 Monad laws
291(5)
The associative law
292(1)
Proving the associative law for a specific monad
293(1)
The identity laws
294(2)
11.5 Just what is a monad?
296(5)
The identity monad
297(1)
The State monad and partial type application
298(3)
11.6 Conclusion
301(1)
11.7 Exercise answers
302(11)
12 Applicative and traversable junctors
313(40)
12.1 Generalizing monads
314(1)
12.2 The Applicative trait
314(3)
12.3 The difference between monads and applicative functors
317(3)
The Option applicative versus the Option monad
317(1)
The Parser applicative versus the Parser monad
318(2)
12.4 The advantages of applicative functors
320(5)
Not all applicative functors are monads
320(5)
12.5 The applicative laws
325(4)
Left and right identity
326(1)
Associativity
326(1)
Naturality of product
327(2)
12.6 Traversable functors
329(2)
12.7 Uses of Traverse
331(6)
From monoids to applicative functors
332(1)
Traversals with State
333(2)
Combining traversable structures
335(1)
Traversal fusion
336(1)
Nested traversals
336(1)
Monad composition
336(1)
12.8 Conclusion
337(2)
12.9 Exercise answers
339(14)
Part 4 Effects and I/O
353(98)
13 External effects and I/O
355(49)
13.1 Factoring effects
356(1)
13.2 A simple IO type
357(6)
Handling input effects
358(4)
Benefits and drawbacks of the simple 10 type
362(1)
13.3 Avoiding the Stack Over flow Error
363(5)
Fteifying control flow as data constructors
363(3)
Trampolining: A general solution to stack overflow
366(2)
13.4 A more nuanced I/O type
368(9)
Free monads
370(1)
A monad that supports only console I/O
371(4)
Pure interpreters
375(2)
13.5 Non-blocking and asynchronous I/O
377(6)
Composing free algebras
379(4)
13.6 Capabilities
383(2)
13.7 A general-purpose I/O type
385(1)
The main program at the end of the universe
386(1)
13.8 Why the IO type is insufficient for streaming I/O
386(2)
13.9 Conclusion
388(2)
13.10 Exercise answers
390(5)
Local effects and mutable state
394(1)
14.1 Purely functional mutable state
395(1)
14.2 A data type to enforce the scoping of side effects
396(8)
A little language for scoped mutation
397(1)
An algebra of mutable references
398(2)
Running mutable slate actions
400(2)
Mutable arrays
402(2)
14 purely functional in-place quicksort
404(6)
14.3 Purity is contextual
405(2)
What counts as a side effect
406(1)
14.4 Conclusion
407(1)
14.5 Exercise answers
408(2)
15 Stream processing and incremental I/O
410(41)
15.1 Problems with imperative I/O: An example
411(3)
15.2 Simple stream transformations
414(10)
Creating pulls
415(6)
Composing stream transformations
421(2)
Processing files
423(1)
15.3 Extensible pulls and streams
424(18)
Effectful streaming computations
430(1)
Handling errors
431(4)
Ensuring resource safety
435(6)
Dynamic resource allocation
441(1)
15.4 Applications
442(1)
15.5 Conclusion
443(1)
15.6 Exercise answers
444(7)
Index 451
Michael Pilquist has been using Scala since 2009, when he was convinced to give it a try by listening to Dick Wall and the Java Posse. He introduced Scala at Comcast and has written a number of open source functional programming libraries, including scodec, simulacrum, and ip4s. He is also the lead maintainer of FS2, a functional streaming library, and contributes heavily to the Type level ecosystem.  Paul Chiusano and Rúnar Bjarnason are recognized experts in functional programming and authors of the first edition of Functional Programming with Scala