👍 For news and articles from Skills Matter, subscribe to our newsletter here.

I just came back from London where I had the opportunity to attend Scala eXchange 2018 and I noticed one really interesting thing: its topic-based approach. Many conferences usually declare some kind of leitmotif, such as “in the light of upcoming Scala 3…”, but Scala eXchange really had a concrete set of topics as a recurring theme throughout the whole programme. Is this a good thing or a bad thing? Let’s see.

To topic or not to topic

For example, earlier this year I said that ScalaDays in Berlin contained a little bit…

Here’s a short digest for all those who are still unfamiliar with the changes and improvements that are coming in Dotty / Scala 3. I’m not presenting anything that’s not already been presented elsewhere; I’m merely taking a bunch of sources — Dotty documentation, conference talks, blogposts, Google groups, SIPs, pull requests, etc. — and combining them into a text that’s (hopefully) easy to read, not diving too deep into any of the upcoming changes, but still providing enough detail to get you all excited about them.

Update: Please keep in mind that this was written in May 2018., …

Photo by Lucien Kolly on Unsplash

Some of you may have read my article on monads. This time I want to talk about monads from a different, more theoretical point of view. It is not mandatory to read the previous article first (in case you haven’t), but if you don’t know anything about the topic, I guess it wouldn’t hurt to become familiar with it before jumping on this one.

Let’s start. Some of you may have heard the popular quote:

A monad is just a monoid in the category of endofunctors, what’s the problem?

Original statement is from Categories for the Working Mathematician by Saunders…

In this short article I will demonstrate the generalized type constraints in Scala — what they are, why we need them and how they are used.

To start, let me show you two Scala puzzles.

Puzzle number one:

def pair[S](s1: S, s2: S): (S, S) = (s1, s2)

What do you think happens if we pass two values of different type to this method? Let’s see:

scala> pair(“foo”, 1)
res0: (Any, Any) = (foo,1)

What happened is that compiler said “OK, first value is a String and second value is an Int, but that’s not really going to work out because I need…

In one of my earlier articles I tried to explain monads in an approachable way. Here’s an attempt to do the same for some other members of the same family — functors and applicative functors. Even though concepts and principles explained here are general in functional programming, mild accent will be (as usual) on Scala.


In case you read the aforementioned article about monads, you may remember how I described them as wrappers around values. Every value wrapped in a monad becomes an object equipped with two methods, unit and flatMap (using Scala convention for naming).

So, if you look…

A few days ago I stumbled upon a StackOverflow question regarding this stuff and while writing my answer I noticed that I wrote a respectable chunk of text. Which is a good indicator for a blog post. Oh and by the way, in case you’re not familiar with any of my previous work, this post will be mostly revolving around Scala (although the concepts presented are quite general in functional programming).

First we will see what’s the difference between no-parenthesis and empty-parenthesis methods. We will see what role this difference plays when converting methods to functions. Eta-expansion as a mechanism…

This article aims to show a couple of techniques to tackle some common problems caused by type erasure in Scala.


Scala has a really strong type system. Existential types, structural types, nested types, path-dependant types, abstract and concrete type members, type bounds (upper, lower, view, context), use-site and declaration-site type variance, support for type polymorphism (subtype, parametric, F-bounded, ad-hoc), higher-kinded types, generalized type constraints… And the list goes on.

But even though Scala’s type system is theoretically very strong, in practice some type-related features are weakened by the restrictions and limitations of its runtime environment — that’s right, I’m looking…

This article explains what ad-hoc polymorphism is, what kind of problems it solves and how to implement the whole thing using the type class pattern.

Types of polymorphism

We’ll start from parametric polymorphism. Say we have some list of items; this could be a list of integers, doubles, strings, whatever. Now consider a method head() which returns the first item from that list. This method doesn’t care if the item is of type Int, String, Apple or Orange. Its return type is the one list is parameterized with and its implementation is the same for all types: “return first item”.

Unlike parametric polymorphism…

Photo by davide ragusa on Unsplash

In my previous post I mentioned how I decided to write about variance despite the fact that there are already several dozen articles about the topic. This is a similar situation. I am aware that this is a drop in the sea. I feel the sea is polluted with complex mathematical explanations involving category theory. Boring explanations which line up one definition after another without providing the gist of things.

I will not get technical, and by technical I mean mathematical. Stephen Hawking said that he was warned that every equation he put into “A brief history of time” (great…

This text aims to explain variance in type parameters both in Java and Scala. There is already a lot of material on this subject in various blogs and articles, but to me, they always felt either too complex, diving straight into advanced features and is hard to follow for someone new to the topic, or too simplistic and merely scratching the surface.

So, here’s my attempt at filling that gap.

First, a little background

I assume most (or all) of you are well acquainted with the concept of polymorphism in object-oriented programming. It’s cool to be able to e.g. test if an array is…

Sinisa Louc

Backend Engineer at MOIA (https://www.moia.io/en), Berlin. I blog about Scala and functional programming in general. Find me on Twitter (link below).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store