Leanpub Header

Skip to main content

Practical FP in Scala

A hands-on approach

Bu kitap % 100 tamamlandıBu kitabın son güncelleme zamanı 2021-09-13.

A practical book aimed for those familiar with functional programming in Scala who are yet not confident about architecting an application from scratch.

Together, we will develop a purely functional application using the best libraries in the Cats ecosystem, while learning about design patterns and best practices.

En düşük fiyat

Ücretsiz!

$19.99

Ödeyeceğiniz Miktar

Yazarın kazandığı

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
3,404
Okuyucular
300
Sayfa
Hakkında

Hakkında

Kitap Hakkında

Practical FP in Scala: A hands-on approach, is a book for intermediate to advanced Scala developers. Aimed at those who understand functional effects, referential transparency and the benefits of functional programming to some extent but who are missing some pieces to put all these concepts together to build a large application in a time-constrained manner.

Throughout the chapters we will design, architect and develop a complete stateful application serving an API via HTTP, accessing a database and dealing with cached data, using the best practices and best functional libraries available in the Cats ecosystem such as Cats Effect, Fs2, Http4s, Skunk, Refined & others.

You will also learn about common design patterns such as managing state, error handling and anti-patterns, all accompanied by clear examples. Furthermore, in the Bonus Chapter, we will dive into some advanced concepts such as MTL and Optics, and will explore Fs2 streams with a few interesting examples.

The book is supplemented by two Scala projects:

Looking for a printed version? You can get a Softcover (paperback) here.

Got some feedback? Please email the author here: pfpscala at gmail dot com.

Bu kitabı Paylaş

Yazar

Yazar Hakkında

Gabriel Volpe

Gabriel Volpe is a Software Engineer, specialized in functional programming, from Buenos Aires, Argentina. He writes code since 2005, mainly Scala and a bit of Haskell, though always using Nix to guarantee reproducibility.

The Leanpub Podcast

Episode 180

An Interview with Gabriel Volpe

İçerik

İçindekiler

  • Preface
  • Acknowledgments
    • People
    • Software
    • Fonts
  • Dependency version
  • Prerequisites
  • How to read this book
    • Conventions used in this book
  • 1. Chapter 1: Best practices
    • 1.1 Strongly-typed functions
      • 1.1.1 Value classes
      • 1.1.2 Newtypes
      • 1.1.3 Refinement types
      • 1.1.4 Runtime validation
    • 1.2 Encapsulating state
      • 1.2.1 In-memory counter
    • 1.3 Sequential vs concurrent state
      • 1.3.1 State Monad
      • 1.3.2 Atomic Ref
    • 1.4 Shared state
      • 1.4.1 Regions of sharing
      • 1.4.2 Leaky state
    • 1.5 Anti-patterns
      • 1.5.1 Seq: a base trait for sequences
      • 1.5.2 About Monad Transformers
      • 1.5.3 Boolean blindness
    • 1.6 Error handling
      • 1.6.1 MonadError & ApplicativeError
      • 1.6.2 Either Monad
      • 1.6.3 Classy prisms
    • 1.7 Summary
  • 2. Chapter 2: Tagless final encoding
    • 2.1 Algebras
      • 2.1.1 Naming conventions
    • 2.2 Interpreters
      • 2.2.1 Building interpreters
    • 2.3 Programs
    • 2.4 Implicit vs explicit parameters
      • 2.4.1 Achieving modularity
      • 2.4.2 Implicit convenience
      • 2.4.3 Capability traits
    • 2.5 Why Tagless Final?
      • 2.5.1 Parametricity
      • 2.5.2 Comparison
    • 2.6 Summary
  • 3. Chapter 3: Shopping Cart project
    • 3.1 Business requirements
      • 3.1.1 Third-party payments API
      • 3.1.2 Identifying the domain
      • 3.1.3 Identifying HTTP endpoints
    • 3.2 Technical stack
      • 3.2.1 A note on Cats Effect
    • 3.3 Summary
  • 4. Chapter 4: Business logic
    • 4.1 Identifying algebras
    • 4.2 Data access and storage
      • 4.2.1 Health check
    • 4.3 Defining programs
      • 4.3.1 Checkout
      • 4.3.2 Retrying effects
    • 4.4 Architecture
    • 4.5 Summary
  • 5. Chapter 5: HTTP layer
    • 5.1 A server is a function
    • 5.2 HTTP Routes #1
    • 5.3 Authentication
      • 5.3.1 JWT Auth
    • 5.4 HTTP Routes #2
    • 5.5 Composing routes
    • 5.6 Middlewares
      • 5.6.1 Compositionality
    • 5.7 HTTP server
    • 5.8 Entity codecs
    • 5.9 HTTP Client
      • 5.9.1 Payment client
      • 5.9.2 Creating a client
    • 5.10 Summary
  • 6. Chapter 6: Typeclass derivation
    • 6.1 Standard derivations
    • 6.2 JSON codecs
      • 6.2.1 Map codecs
    • 6.3 Orphan instances
    • 6.4 Identifiers
      • 6.2.1 GenUUID & IsUUID
      • 6.2.2 Custom derivation
    • 6.5 Validation
    • 6.6 Http4s derivations
    • 6.7 Higher-kinded derivations
    • 6.8 Summary
  • 7. Chapter 7: Persistent layer
    • 7.1 Skunk & Doobie
      • 7.1.1 Session Pool
      • 7.1.2 Connection check
      • 7.1.3 Queries
      • 7.1.4 Commands
      • 7.1.5 Interpreters
      • 7.1.6 Streaming & Pagination
    • 7.2 Redis for Cats
      • 7.2.1 Connection
      • 7.2.2 Interpreters
    • 7.3 Health check
    • 7.4 Blocking operations
    • 7.5 Transactions
      • 7.5.1 Compositionality
    • 7.6 Summary
  • 8. Chapter 8: Testing
    • 8.1 Functional test framework
    • 8.2 Generators
      • 8.2.1 About forall
      • 8.2.2 Application data
    • 8.3 Business logic
      • 8.3.1 Happy path
      • 8.3.2 Expectations
      • 8.3.3 Empty cart
      • 8.3.4 Unreachable payment client
      • 8.3.5 Recovering payment client
      • 8.3.6 Failing orders
      • 8.3.7 Failing cart deletion
    • 8.4 HTTP
      • 8.4.1 Routes
      • 8.4.2 Clients
    • 8.5 Law testing
    • 8.6 Integration tests
      • 8.6.1 Shared resources
      • 8.6.2 Postgres
      • 8.6.3 Redis
    • 8.7 Summary
  • 9. Chapter 9: Assembly
    • 9.1 Logging
    • 9.2 Tracing
      • 9.2.1 Ecosystem
    • 9.3 Configuration
    • 9.4 Modules
    • 9.5 Resources
    • 9.6 Main
    • 9.7 Summary
  • 10. Chapter 10: Ship it!
    • 10.1 Docker image
      • 10.1.1 Optimizing image
      • 10.1.2 Run it locally
    • 10.2 Continuous integration
      • 10.2.1 Dependencies
      • 10.2.2 CI build
      • 10.2.3 Nix shell
      • 10.2.4 Furthermore
    • 10.3 Summary
  • 11. Bonus Chapter
    • 11.1 MTL (Monad Transformers Library)
      • 11.1.1 Managing state
      • 11.1.2 Accessing context
    • 11.2 Optics
      • 11.2.1 Lenses
      • 11.2.2 Prisms
    • 11.3 Aspect Oriented Programming
      • 11.3.1 Tofu's Mid
    • 11.4 Concurrency
      • 11.4.1 Producer-Consumer
      • 11.4.2 Effectful streams
      • 11.4.3 Interruption
      • 11.4.4 Multiple subscriptions
      • 11.4.5 (Un)Cancelable regions
      • 11.4.6 Resource safety
      • 11.4.6 Finite State Machine
    • 11.5 Summary

Ücretsiz örnek bölümleri alın

Click the buttons to the right to get the free sample in PDF or EPUB, or read the sample online here

Yazarın Ayrıca

Yazarın Ayrıca

Leanpub Önkoşulsuz, Risksiz, %100 Mutluluk Garantilidir

Leanpub'tan yaptığınız alışverişlerde, 60 günlük sürede %100 iade garantisi mevcut, bunun için sadece iki tıklama yeterli. Detaylar için (ingilizce) kullanım sözleşmesini okuyunuz.

10$ değerinde bir satıştan 8$, 20$ değerinde bir satıştan 16$ kazanın

7,99$ veya üzeri satışlarda %80 telif, 0,99$ ile 7,98$ arasındaki satışlarda 50 sent sabit ücret düşülerek %80 telif ödüyoruz. 10$'lık bir satıştan 8$, 20$'lık bir satıştan 16$ kazanıyorsunuz. Yani, kitabınızın iade edilmemiş 5000 kopyasını 20$'dan satarsak, 80.000$ kazanacaksınız.

(Evet, bazı yazarlar Leanpub'da bundan çok daha fazlasını kazandılar.)

Gerçekte, yazarlar Leanpub'da yazarak, yayınlayarak ve satarak 14 milyon dolardan fazla kazandılar.

Leanpub'da yazmak hakkında daha fazla bilgi edinin

Ücretsiz Güncellemeler. DRM İçermez.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Leanpub'ın e-kitap formatları ve bunları nerede okuyabileceğiniz hakkında daha fazla bilgi edinin

Leanpub üzerinde Yazın ve Yayımlayın

Authors and publishers use Leanpub to publish amazing in-progress and completed ebooks, just like this one. You can use Leanpub to write, publish and sell your book as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Leanpub üzerinde nasıl yazabileceğinizi öğrenin