Mastering Functional Programming Functional Techniques for Sequential and Parallel Programming with Scala
In large projects, programmers tend to get overwhelmed by their complexity. It can be hard to keep track of all the interdependencies in the code-base and how its state changes on runtime. The solution to these problems is Functional Programming, a paradigm specifically designed to deal with the com...
Uloženo v:
| Hlavní autor: | |
|---|---|
| Médium: | E-kniha |
| Jazyk: | angličtina |
| Vydáno: |
Birmingham
Packt Publishing, Limited
2018
Packt Publishing Limited Packt Publishing |
| Vydání: | 1 |
| Témata: | |
| ISBN: | 9781788620796, 1788620798 |
| On-line přístup: | Získat plný text |
| Tagy: |
Přidat tag
Žádné tagy, Buďte první, kdo vytvoří štítek k tomuto záznamu!
|
Obsah:
- Chapter 7: The Idea of the Type Classes -- Rich Wrapper pattern -- Motivation -- Implicit conversions -- Rich Wrapper -- The Type Class pattern -- Interpretation of the Type Class pattern -- Injectable interfaces -- Toolboxes -- Type classes in different languages -- Summary -- Questions -- Chapter 8: Basic Type Classes and Their Usage -- A motivation for organizing type classes into systems and libraries -- The Cats library for purely functional programming -- The structure of the library -- Core -- Type class hierarchy -- Abstract methods -- Concrete methods -- Laws -- Syntax -- Instances -- Data -- Infrastructure synergy -- Type classes -- Monad -- Writer effect type -- The tailRecM method -- Functor -- Applicative -- Motivation -- Applicative type class -- Implementation of the type class -- Monoid -- Implementation for Either -- MonoidK -- Traverse -- Summary -- Questions -- Chapter 9: Libraries for Pure Functional Programming -- Cats effect -- ProductR -- IO - the concurrence data type -- Referential transparency -- Inversion of control -- Asynchrony with IO -- Blocking example -- Concurrency infrastructure -- Running tasks in bunches -- Heavy load with blocking -- Synchronous tasks -- Constructing asynchronous tasks -- Asynchronous API -- Asynchronous example -- Fibers -- The computation -- IO combination without Fibers -- IO combination with Fibers -- Canceling Fibers -- Bracket -- Server-side programming -- The architecture of a server-side application -- Communication protocol -- The software architecture of a server -- Example specification -- Orchestration and infrastructure -- Docker -- Docker-compose -- Dockerfiles -- Backend architecture -- Model -- Database layer -- Server-side programming -- Querying the server -- Summary -- Questions -- Chapter 10: Patterns of Advanced Functional Programming -- Monad Transformers
- Cover -- Title Page -- Copyright and Credits -- Dedication -- Packt Upsell -- Contributors -- Table of Contents -- Preface -- Chapter 1: The Declarative Programming Style -- Technical requirements -- Principles of declarative programming -- Example - go-to versus loops -- Example - nested loop -- Don't Repeat Yourself (DRY) -- Declarative versus imperative collections -- Filtering -- Declarative programming in other languages -- Summary -- Questions -- Chapter 2: Functions and Lambdas -- Functions as behavior -- Functions in functional programming -- Higher-order functions -- Understanding lambda functions -- The concept of functions in different programming languages -- Summary -- Questions -- Chapter 3: Functional Data Structures -- Collections framework -- Imperative collections -- Functional collections -- Algebraic approach -- Effect types -- Try -- Option -- Data structures in different programming languages -- Summary -- Questions -- Further reading -- Chapter 4: The Problem of Side Effects -- Side effects -- Mutable states -- Pure functions -- Referential transparency -- Generally encountered side effects -- Error -- Absence of result -- Delay and asynchronous computations -- Logging -- Input-output operations -- But how do we get rid of the side effects? -- The pure functional paradigm in different languages -- Summary -- Questions -- Chapter 5: Effect Types - Abstracting Away Side Effects -- Turning effects into data -- The sequential combination of effects with Monads -- Introducing the map function -- Introducing the flatMap function -- Summary -- Questions -- Chapter 6: Effect Types in Practice -- Future -- Motivation and the imperative example -- Abstraction and the functional example -- Composing Futures -- flatMap generalized -- Either -- Reader -- Functional solution -- Summary -- Questions
- The specialization of effect types -- An application with multiple side effects -- Asynchrony -- The side effect of errors -- Monad Transformers -- Generalizing the pattern -- Tagless Final -- Programming to capabilities -- Implementations -- Execution semantics abstraction -- Computation as a value -- Free Monad -- Type-level programming -- A naive implementation of the heterogeneous list -- Type-level solution to the heterogeneous list problem -- Reclusive implicit resolution -- Debugging type-level computations -- Libraries for type-level programming -- Summary -- Questions -- Chapter 11: Introduction to the Actor Model -- Overview of parallelism solutions -- Traditional model synchronization on monitors -- Synchronization -- Problems with the traditional model - race conditions and deadlocks -- The actor model as a replacement for the traditional model -- Deadlock example revisited -- Summary -- Questions -- Chapter 12: The Actor Model in Practice -- Akka overview -- Principles of Akka -- Encapsulation -- Messaging -- No leaking of mutable state -- Fault-tolerance and supervision -- Messaging guarantees -- Asynchrony -- Defining, creating, and messaging actors -- Callbacks -- Supervision -- Context and references -- Managing the actor hierarchy -- Managing the life cycle -- Supervision -- Creating actors -- Actor parameters -- Working with actor systems -- Task specification -- Implementation -- Summary -- Questions -- Chapter 13: Use Case - A Parallel Web Crawler -- Problem statement -- The graph structure of the web -- Collecting information from the graph -- Parallel nature of the task -- Sequential solution -- A parallel solution with Akka -- Strategy -- Implementation -- Caveats -- Visited links -- Fault tolerance -- Counting the responded actors -- Real-world side effects -- Summary -- Appendix A: Introduction to Scala
- Motivation for using Scala -- Scala infrastructure -- Scala interpreter -- SBT build tool -- Variables and functions -- Control structures -- If and While -- For -- Pattern matching -- Partial functions -- Inheritance model -- Classes -- Traits -- Singleton objects -- Summary -- Assessments -- Other Books You May Enjoy -- Index
- Mastering Functional Programming: Functional techniques for sequential and parallel programming with Scala

