Friday, October 29, 2021
Have you ever had a program try to read a file after the handle had been closed, or query a database after the transaction had been committed? How about shadow a variable and accidentally use the wrong one?
Linear types require that values are used once and only once. In this talk, we learn about how linear types can be used in Scala programs to prevent runtime errors like these by detecting them at compile time.
We begin with some motivating examples before diving into what linear types are and how to implement them in Scala. We then introduce linear types as a substructural type system, and touch on implementations in Rust and Haskell. Next, we see how Scalafix can be used to extend the Scala compiler through custom linting rules. Finally, we look at a linear types implementation in Scala using Scalafix, and apply it to the real-world examples we started with.
Attendees will leave this talk with a new tool in their functional programming toolbox that they can start using to solve real-world problems.
Let's live-code an effect system in Scala. We'll begin by describing an effectful program that we would like to write as a pure value. Then we will write a toy effect system to be able to run it. For our effect system, we will choose from monad transformers, free monads, tagless final, or reader monads.
Download these images to your phone and post using the Instagram app.