Getting (More) Work Done with Extensible Effects in Scala

schedule May 22nd 01:45 - 03:15 PM place Green Room people 67 Interested

This hands-on, code-centric session teaches attendees how effectful functional programming can be used to tackle the often messy, IO-heavy problems found in industry. We will use the Scala Eff monad library to incrementally build and extend a directory scanner.

Participants without any previous background in Eff or effectful FP have a smooth on-ramp. A series of refactoring exercises incrementally transforms an imperative program into a purely functional, effectful programming, introducing the Eff API along the way:

  • The Async effect to model asynchronous requests
  • Using Either effects for error handling
  • Using Reader effects for dependency injection
  • Writer effects for logging

For those with previous Eff experience, or have done my Eff workshop at Lambdajam 2017, there are new exercises that dig deeper into Eff:

  • Programming stateful systems with the State effect
  • Combining effects and functional optics
  • Two different approaches to side-effects: catch-all IO vs focussed effect DSLs

The Eff library is an implementation of Extensible Effects in Scala, developed by Eric Torreborre. It is inspired by Oleg Kiselyov’s Haskell paper ‘Freer Monads, More Extensible Effects’ . Like Monad Transformer stacks and the Free monad, it provides an organising principle for the construction of pure functional programs.

Materials are available at benhutchison Getting Work Done With Extensible Effect. Solutions are included for all exercises.

 
 

Outline/Structure of the Code Jam

Each exercise provides some background context, and sets some tasks for the participant to tackle. All exercises use a common example scenario, and later ones build on learning from earlier.

There are solutions provided for all exercises in a subproject, so that participants can check their work, and/or continue if they get stuck.

There are four core exercises:

  • The Async effect to model asynchronous requests
  • Using Either effects for error handling
  • Using Reader effects for dependency injection
  • Writer effects for logging

Three additional advanced-level exercises:

  • Programming stateful systems with the State effect
  • Combining effects and functional optics
  • Two different approaches to side-effects: catch-all IO vs focussed effect DSLs

Learning Outcome

  • Can use the Eff library to tackle applied problems
  • Understand of how effectful functional programming can be used in industry

Target Audience

Programmers interested in applied functional programming in Scala

Prerequisites for Attendees

Required knowledge

  • Some background in functional programming concepts
  • Familiarity with Scala

Preparation

Previously wifi at the Lambdajam venue has been extremely limited. It's important that participants perform the two setup steps below *beforehand* to follow along with the exercises

schedule Submitted 1 year ago

Public Feedback

comment Suggest improvements to the Speaker