Menu

Testing in the wild

Writing tests seems like a wonderful idea in theory but real systems can be a real pain to test. Today I want to show a few tips on how to use specs2 + ScalaCheck to make some real-world testing somewhat bearable. I am currently refactoring a big piece of code....

Optimizing Tagless Final – Part 2 – Monadic programs

In our previous post on optimizing tagless final programs we learned how we could use the sphynx library to derive some optimization schemes for your tagless final code. In case you missed it and want to read up on it, you can find it right here or you can watch...

Typedapi or how to derive your clients and servers from types

In this blog post, I will show you how to leverage Scala’s type system to derive an HTTP client function from a single type. This will also be the story of how I started to work on Typedapi which is basically the attempt to bring Haskell’s Servant to Scala. Servant...

Shared State in Functional Programming

Newcomers to functional programming (FP) are often very confused about the proper way to share state without breaking purity and end up having a mix of pure and impure code that defeats the purpose of having pure FP code in the first place. This is the reason that has motivated...

Tagless Final algebras and Streaming

There have been a couple of really nice blog posts about Tagless Final and some related topics. However, I have faced some design problems when writing some algebras and haven’t seen anybody talking about. So please let me introduce this problem to you. Algebra definition Given the following data definition:...

Product with Serializable

A somewhat common Scala idiom is to make an abstract type extend Product with Serializable. There isn’t an obvious reason to do this, and people have asked me a number of times why I’ve done this. While I don’t think that Product or Serializable are particularly good abstractions, there’s a...

Rethinking MonadError

MonadError is a very old type class, hackage shows me it was originally added in 2001, long before I had ever begun doing functional programming, just check the hackage page. In this blog post I’d like to rethink the way we use MonadError today. It’s usually used to signal that...

Optimizing Tagless Final – Saying farewell to Free

The Tagless Final encoding has gained some steam recently, with some people hailing 2017 as the year of Tagless Final. Being conceptually similar to the Free Monad, different comparisons have been brought up and the one trade-off that always comes up is the lack or the difficulty of inspection of...

Announcement: cats 1.0.0

The cats maintainer team is proud to announce the cats 1.0.0 release. Cats has been striving to provide functional programming abstractions that are core, modular, approachable and efficient. Cats 1.0.0 marks the point where we believe that our API is robust and stable enough to start guarantee backward binary compatibility...

Who implements the typeclass instance?

The typeclass pattern in Scala invites you to place implementation-specific knowledge directly in the typeclass instances, with the interface defined as the typeclass’s abstract interface. However, GADTs permit a different organization of code. It is even possible to define a typeclass that seems to do nothing at all, yet still...