This event has ended. View the official site or create your own event → Check it out
This event has ended. Create your own
View analytic
Sunday, November 13 • 1:40pm - 2:00pm
Using CoProducts to stitch together algebras for scalable complexity in functional program design

Sign up or log in to save this to your schedule and see who's attending!

Specifying an algebra, in the form of sealed case class hierarchies, to describe your program data domain, operations, and result conditions is a natural and common design pattern. But as your program does more, its algebra can become enormous and cumbersome. You will want to begin splitting your algebra into smaller domains to focus on specific concerns. By doing so you can reduce the scope of knowledge required to work in a given algebra, while building smaller, less monolithic interpreters. This talk goes through an example of designing a model for a realistic microservice, and then breaking it down into more discrete, focused concerns. Then we will use Cats Copproduct (with a mention to the Shapeless Coproduct) type to tie the separate algebras back together so the entire program can employ the capabilities of main different domains selectively. We will describe how this technique is also useful for stitching together different Free monad libraries when using the interpreter pattern. Finally we will talk about how this is one solution to the Expression Problem, but there are others out there.

avatar for Scott Maher

Scott Maher

Sr Tech Lead, Twilio
Scala! Distributed systems! Communications protocols! Punctuation expressing excitement!

Sunday November 13, 2016 1:40pm - 2:00pm