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.

Last updated