Skip to content
Workshop On Tagless Final Interpreters
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Tagless Final and Abstract Effects


One of the core tenants of functional programming, is that the effects our programs use should be expressed in the type signatures of our functions.

For example

  • scala.Option is an effect that indicates a value may, or may not be present.
  • scala.util.Try is an effect that represents a computation that may fail, with an exception

As with all aspects of functional programming, we strive for composability. In Haskell a common approach to composing these effect types in monad transformers. However, in Scala this approach suffers from poor performance, and poor type inference.

One solution to this that has recently gained popularity is the Free Monad, which is an effect absent of interpretation. i.e. it has no inherent effect, but its effect can be defined in an arbitrary way by evaluating it using an interpreter. The free monad also has some draw backs. Performance can be an issue and there is a lot of boiler plate.

An alternative is to use Tagless Final which can be used in most of the same scenarios as the Free Monad, but achieves better performance, less boiler plate and is more simple.

The Workshop

The workshop is made up of practical exercises that introduce the tagless final style, and demonstrate how this style can be used in real world use cases.

Part 1

The first is a practical introduction to the concept of Tagless Final Interpreters with a simple first order language that can express integer arithmetic. Attendees will implement a simple evaluator for this language in the tagless final style, and show that the final and initial encodings are equivalent.

Part 2

The second part consists of several exercises that build out a simple reading list application using the tagless final style.

The exercises will demonstrate;

  • The use of higher-order tagless final encoding
  • Composing tagless final algebras
  • Using typeclass constraints to abstract over what capabilities are needed in different scenarios. Including, sequential computations with cats.Monad, error handling with cats.MonadError and parallelism with cats.Parallel



  • Java 8 & SBT must be installed.
  • Clone this repository git clone
  • Run sbt update in the root of the project to download and cache all the dependencies.
  • Import the project into your favorite editor, see below for options.


There are several editors for scala


  • Part1 – Interpreting integer arithmetic
  • Part2a – Defining the domain model for the reading list application
  • Part2b – Composing algebras with the tagless final encoding
  • Part2c – Adding error handling
  • Part2d – Adding parallelism
  • Part2e – Adding a real repository implementation, using the file system.


There are solutions to each exercise in the the /answers subdirectory.


You can’t perform that action at this time.