Uniting Church and State: FP and OO Together

This is a post about church and state, and how we can unite the two for a better world, while avoiding unfortunate side effects.

Political metaphors aside, this really is a post about Church—Alonzo Church—and how we can use his idea of Church encoding to unite pure FP and imperative OO to achieve, if not a better world, at least better code.

Continue reading…

Newsletter 16: It's Book Time!

Hi,

Greetings from Copenhagen on the eve of Scala Days. In this newsletter I have a few things to talk about… conference talks, training, type tetris, and—oh—making all of our books free and open source.

Continue reading…

Playing "Type Tetris"

I’m going to try to explain a technique called type-driven development. It’s where we write as much code as possible using only types, deferring any non-type details until later. We’ll see how it helps us as we develop a small service that supports authentication. Along the way we’ll see how we can use abstract types, the ??? method, and the Scala compiler itself to converge towards a good solution to our task.

Since type-driven development doesn’t sound very fun, I like to call it “Type Tetris”. How is programming with (only) types like Tetris?

Continue reading…

The Free Monad with Multiple Algebras

In this post I will look at the machinery that makes it possible to use Free with more than one algebra at once: Coproducts and the Inject type class. This technique was first described in the paper Data types à la carte, and Cats and other libraries provide implementations. However we’re going to build our own implementation in this post, so we understand how it all works. I’m going to assume you understand Free at a basic level. If not, there are several good posts that introduce the concept.

Continue reading…