Posts

Article hero image

Type Gymnastics with Builders - Part 8 - Show me the Code

This is a post-credits bonus post that shows the complete and finished builder code.

Article hero image

Type Gymnastics with Builders - Part 7 - Why bother?

While the builder pattern is a powerful tool for creating complex objects in a type-safe manner, it is easy to discard it given its complexity and boilerplate. This post details the situations where builders are particularly useful.

Article hero image

Type Gymnastics with Builders - Part 6 - Can You Hold This For Me?

This post takes the ideas from previous posts to get rid of some boilerplate, and concluding the “how” portion of the series.

Article hero image

Type Gymnastics with Builders - Part 5 - Order, Order, I Say!

This post adds type-level ordering to the builder, enforcing when fields can be set. It introduces explicit constraints on configuration order: host/port first, maxConnections/connectionTimeout before algebras, and HealthChecks last. Read more to know how.

Article hero image

Type Gymnastics with Builders - Part 4 - Flexibility

This post makes the builder API more flexible by allowing incremental health check additions without losing type safety. We will see how withHealthChecks is changed from replace to append, so calls accumulate instead of overwrite.

Article hero image

Type Gymnastics with Builders - Part 3 - Errors Are UX Too

This post talks about making the error messages cleaner and clearer. You might want to read this one since it involves typeclasses. ๐Ÿ˜‰

Article hero image

Type Gymnastics with Builders - Part 2 - Know Your Limitations

This post extends a prior typesafe Builder Pattern and demonstrates where it breaks down with a more complex AppConfig[F[_]] that wires Auth, Users, Books, and multiple HealthChecks. It presents a generic AppBuilder using phantom Option type parameters and extension ops to enforce field presence while allowing any order.

Article hero image

Type Gymnastics with Builder Pattern

The Builder pattern provides a way to construct complex objects step by step with a fluent API, where each method call returns the builder itself, allowing for method chaining. Let us play some type gymnastics in Scala to ensure type safety when creating objects via the builder pattern.

Article hero image

Understanding Contramap

A contramap is defined as the converse of the map. I have never been satisfied with the definition. In this post, I will explain the concept in a way that is easy to internalize.

Article hero image

Scala 2 Symbols

This post provides a concise overview of key symbols used in Scala 2, such as symbols for function types, function literals, import renaming, and more. It serves as a quick reference for Scala developers to understand the functionality and application of these essential symbols.