Be Smart, Constrain Your Types to Free Your Brain!

Photo by KAL VISUALS on Unsplash

Be Smart, Constrain Your Types to Free Your Brain!

Presentation at Functional Scala 2022

Play this article

Admit it: You have used a String to model email values, even though most strings aren’t valid emails (don’t worry, we all have!). Imprecise data models are easy, but they crash applications and corrupt external systems. On the other hand, precise data models take time and generate boilerplate.

So-called newtype libraries have stepped up to the challenge, making it easier to model data precisely using runtime validation. However, newtype libraries aren’t able to validate constants at compile-time.

Enter ZIO Prelude Smart Types, which make it simple to model data types precisely, without any boilerplate, runtime overhead, or compile-time overhead. ZIO Prelude Smart Types work at compile-time and runtime, and they have a uniform API across Scala 2 & 3.

Watch the recording:

💡
You can find the slides here