My fs2 (was scalaz-stream) User Notes
  • Introduction
  • Foundations
  • Design Patterns
    • Category Theory Express Design Patterns
    • Category Theory
      • Semigroup
      • Monoid
      • Functor
      • Applicative
      • Products\/Coproducts
      • Monad
      • Free Monad
    • Category Theory for fs2
  • fs2 Core Model
    • Streams and Graphs
    • Composability
    • API
    • Effects
      • fs2 Effects
    • Smart Constructors and Combinators
  • fs2 Basics
    • Technical Setup
    • Simple Streams
    • Effectful Streams
    • Error Handling and Resource Management
    • Sinks
    • Channels and Exchanges
    • Combining Streams: Wye and Tee
    • Refs
  • Cookbook
    • Recipe: onFinish for Task
    • Recipe: Changing Seq[A] to A
    • Recipe: Debugging with toString
    • Recipe: Retrieving Web Pages
    • Recipe: Converting an Iterator to a Stream
    • Recipe: Data-Driven Stream
    • Recipe: Evaluate a Task Periodically
    • Recipe: Delay running a stream
    • Recipe: Stop an infinite Stream when you want to
    • Recipe: CSV Parsing with univocity
    • Recipe: CSV Parsing with node.js csv-parse using Readable => Stream
  • fs2 Examples
    • Akka Examples
    • Cafe
    • More Than One Stream
Powered by GitBook
On this page

Was this helpful?

  1. Design Patterns

Category Theory

PreviousCategory Theory Express Design PatternsNextSemigroup

Last updated 5 years ago

Was this helpful?

All of these concepts are covered quite nicely in the book this scala . You should read it. It covers the motivatations behind sstreams and its basic components. It focuses less on using sstream to solve domain problems. This section acts more like a glossary for the rest of the material. It is designed to provide an ultra-light understanding of concepts in order to better, and more succinctly describe, sstreams. For a more extended introduciton, you can also check out .

There are many deep thoughts about semigroups, applicatives, et al. We will bypass all of the deep thoughts and summarize the key abstraction that each of these has. We also do not try to describe supporting detail since you can look many of these concepts up on your own. In all cases, scalaz provides these concepts as classes that can be instantiated for common types such as a List or Set or in some cases String. Scalaz uses classes to represent these design patterns and creates instances of them for its library as well as for your use. These category theory classes play two roles. First, it acts as evidence to a function that the type of one of its parameters satisfies certain properties that will be needed to perform the computation. Second, it provides the Strategy design pattern that is used to perform the calculation in the function and it can be called directly to perform the computation.

The classes that implement these components can be thought of as "small" design patterns because they represent abstract concepts, such as "addition" or "multiplication" for different types of objects. They are labelled "small" because they are very abstract and provide a simple operation.

book
learning scalaz