Patrick Premont - Types for Reliable Lookups
Channel: Scala Up North
Date: 2015-10-16

Looking up data in a map is a potentially brittle operation. It must return an Option since it provides no guarantee that the element we seek is present. Handling this is cumbersome, and may lead us to write error handling code that turns out to be unreachable, or worse, to omit it when it is required.

We will see how Scala's type system lets us express referential integrity constraints. We will present an associative array whose lookup operation never fails, allowing us to eliminate one more class of errors from our programs. We then look at examples built with the total-map library (http://github.com/boldradius/total-map), examine comparative benchmarks and review limitations and applicability.

About Patrick Prémont

Patrick Prémont is a Functional Programming Architect at BoldRadius Solutions where he helps clients build reliable applications in Scala and ScalaJS. For a decade he led the development of a portable game development platform: first as a startup founder, and later as a Technical Director at Electronic Arts. He first encountered functional programming with the Miranda language, more than 20 years ago, and took up Haskell professionally 6 years ago while building web applications and tackling distributed AI problems.