Infinite data is a large concern in streaming, but as a concept it’s impossible to fathom. In this tutorial, we’ll develop an intuition for infinite streams in fs2. We’ll see how fs2 describes infinite processes, and build a model for understanding them.
You will learn
How to create pure functional streams, including infinite ones.
How to transform streams.
How to break a stream down into a series of steps.
You should already
Know a little bit of pure functional programming.
Be able to transform lists using functions like
This tutorial only deals with pure streams — you don’t need to know
IO or side-effects to follow it.
Assuming you’re familiar with SBT, create a build.sbt file with the following contents.
ThisBuild / scalaVersion := "3.2.0" ThisBuild / libraryDependencies += "co.fs2" %% "fs2-core" % "3.7.0" ThisBuild / initialCommands := s""" import fs2._ """
Then enter the console with