F-Bounded Polymorphism: Recursive Type Signatures in Scala

Have you seen a type signature like this before?

trait T[U <: T[U]]

F-bounded polymorphism (a.k.a self-referential types, recursive type signatures, recursively bounded quantification) is a powerful object-oriented technique that leverages the type system to encode constraints on generics.

Marconi Lanna explains how to define and use F-bounded types in Scala, enlisting the compiler to enforce advanced trait semantics, while greatly reducing and simplifying unit tests.

Further Resources

Copyright © 2017 ProTech. All Rights Reserved.

Sign In Create Account

Navigation

Social Media