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.