
Demonstrates imperative CSV processing of lego set data using a buffer, parsing fields, and ignoring malformed lines, then compares with iterator and stream approaches in FS2 to show tradeoffs.
Extend an imperative csv processing algorithm by filtering with a predicate and enforcing a limit on results, using option's future and careful counter placement.
Process a csv file with functional streams by loading lines into a list, mapping and filtering optional values, and taking a maximum number of results.
Learn to create finite streams with fs2 in Scala, using emit for single values, emits for sequences, including empty streams and vectors, and inspect content by converting to lists.
Explore lazy streams using iterate to generate an infinite stream of natural numbers, starting from one, applying a next value function, and safely inspect by taking the first five elements.
Implement iterate in terms of unfold using an initial value and a next value function to produce an infinite stream of states.
This lecture demonstrates flatMap on pure streams, showing how mapping to i and i+1 flattens into a single stream or list, including infinite streams and lazy evaluation.
Pure streams in FS2 are lazy, recipe-based collections you can create and combine. To realize elements, call toList, but beware infinite streams that never end.
Covary a pure stream into io to enable io-specific combinators for effectful streams in fs2. The example prints one, two, three to the console after covarying to io.
This lecture explains unfolding in functional streams, showing how an option signals termination and a pair of value and state drives alphabet generation, with IO side effects wrapping the process.
Explore functional streams in Scala with FS2 by building and running streams, inspecting values like 42, and using repeat to create infinite side-effecting streams with finite samples via take.
Learn how to use evalMap, evalTap, and evalFilter in functional streams for scala with fs2 to perform effects, print elements, and filter streams with side effects.
Implement eyeball every as a finite-duration sleep loop that executes an effect, emits a value, and repeats indefinitely. Take a finite sample to observe outputs from the infinite stream.
Explore throttling using the time method in fs2, applying a meter with a rate like 1/2 to regulate emissions, and account for execution time to emit immediately or after waiting.
Explore the chunk API by building chunks from elements, arrays, and singletons, and compare them with lists. Learn concatenation, indexing, and the compact method to create a single array-backed chunk.
Explore the running max exercise in functional streams for Scala with FS2, building a max over chunks from a neutral element through an accumulator and state updates.
Pull-based streams emit only when asked, delivering elements in chunks for performance, while pools act as stream processes for stateful transformations, and pipes with the through operator build pipelines.
Create a ref initialized to zero, simulate processing 30 items with a processor that updates the ref, and emit progress updates every 100 milliseconds while draining the stream. Run a separate progress tracker stream that reads the current count, prints a progress message with the calculated percentage of items processed, and illustrate why the processor goes on the left and the progress tracker on the right as a background task.
Demonstrate a parallel version of nirvana, processing jobs with parEvalMap to boost concurrency, while comparing unbounded, bounded, and ordered vs unordered execution.
Explore fixed delay streams in fs2 to enforce a 2-second pause between elements, accounting for processing time. Use the spaced method with duration and stream to compare with fixed rate.
Explore awake every and wait delay streams in FS2, showing how emissions are timed, compare fixed rate and fixed delay semantics, and observe duration impacts on cadence.
Explore communication patterns in functional streams: interruption signals, value transfer between producers and consumers, multi-producer channels with buffering, and publish-subscribe topics and queues with buffering.
Explore backpressure with topics by modeling a producer and consumer using a buffer that slows production to prevent data loss, ensuring sequential processing.
Define a car position with coordinates, publish updates to a topic, subscribe with a Google map updater and a driver notifier, and drain the stream after processing.
Explore concurrent patterns in fs2 by implementing a producer and consumer using an unbounded queue, a shared io ref, and stream integration to monitor the ref while running concurrently.
See how backpressure is handled with queues in functional streams for Scala with FS2. A fast producer outpaces a slow consumer, while the queue buffers thousands of elements.
Many applications involve dealing with large flows of data. Examples are processing files in ETL jobs, reading results from a database or getting a big response from http calls. Handling large amounts of data often means sacrificing either readability or performance.
With streams, you can get the best of both worlds:
- Data is processed using a constant amount of memory, even if the total amount of data is very large
- The processing is built declaratively as if you were dealing with regular Lists or Sequences, with high level methods such as map, filter and flatMap
Furthermore, streams in FS2 are effect-aware. They work in the context of an effect monad like IO, which enables them to do all sorts of useful stuff such as processing elements in parallel, throttling, retrying on failure and many more.
In this course we will turn streams inside out and learn things like:
- Create and combine pure streams
- Add effects to our streams and learn how to compose them
- Handle errors & resources safely
- Apply patterns involving time, such as retries, throttling and debouncing.
- Build our own stream transformations with Pulls and Pipes
- Handle concurrency using many different patterns
- Communicate between streams using primitives such as Signals, Channels, Topics and Queues
Join me in this journey and add yet another amazing tool to your functional programming toolkit!