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. fs2 Core Model

API

The API was designed to be highly functional. Instead of working with complex class objects and call methods on these object, most components of fs2 were designed to work with simple objects created through smart constructors and functions you provide. fs2 uses a rich combinator library to build up operations on data and connect stream fragments. fs2 does not focus on object oriented methods, but functional ones, using functions.

The API is not designed to address a domain specific area, such as flatfile processing or http request-response servicing. You will build up domain specific stream fragments to support your application.

Converting a stream fragment to a runnable stream requires a good understanding of where you want your results to go. In most cases, turning a stream fragment into stream results in an application specific F environment--a fs2 Task being a common environment.

Before you change a stream fragment into a runnable stream, you need to decide if the outputs of the stream are needed or if you are only processing the stream for side effects e.g. writing something to a file. In all cases, you take a runnable stream, run it, which creates your F context. Then you execute that F context as appropriate. For example, if F is a Task you would call unsafeRun on the task.

PreviousComposabilityNextEffects

Last updated 5 years ago

Was this helpful?