F-Bounded Polymorphism: Recursive Type Signatures in Scala

F-Bounded Polymorphism: Recursive Type Signatures in Scala

Tags:

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

About the Author

This post is part of Northeast Scala Symposium 2015

If you liked this post you'll probably be interested in these:

0 Comments

Comments