LambdaConf 2015 - Programs as Values  Pure Composable Database Access in Scala   Rob Norris
Channel: Confreaks
Date: 2015-12-31

FP is often glibly described as "programming with functions", but we can equivalently say that FP is about programming with values. Functions are values, failures are values, effects are values, and indeed programs themselves can be treated as values. This talk explores some consequences of this idea of programs-as-values by looking at doobie, a pure-functional database library for Scala. We will examine the low-level implementation via free monads over algebras of the JDBC types, and show how this naturally enables an expressive and safe high-level API with familiar, lightweight, and composable abstractions including streaming result sets, and trivial compatibility with other pure libraries like Remotely and HTTP4s. Even if you are not in the market for a database layer, this talk will provide a practical outline for a general solution to dealing with terrible APIs (like JDBC) in a principled way.