Opaque types: understanding SIP-35 – Erik Osheim
Channel: Typelevel
Date: 2018-04-03

Proposed in SIP-35, opaque types introduce a way to define types which only exist at compile-time. Despite some superficial similarities to value classes, opaque types are significantly more flexible and introduce a number of exciting new possibilities in the Scala design space.

Opaque types are motivated by a number of different concerns:

- desire for a non-class type that exists only at compile-time
- efficiency concerns with value classes
- limitations of existing type aliases
- need to better support phantom types, type tags, etc.

This talk will introduce opaque types, compare them to type aliases and value classes (their two nearest cousins) and then walk through some examples of using opaque types. The focus will be on advantages of using opaque types versus other encodings, including looking at how various types are represented by the JVM at runtime. The talk does not assume in-depth knowledge of the Scala compiler and will motivate the code using plausible real world examples.

Attendees will come away from this talk with a better understanding of what SIP-35 means, why it was proposed, and how it could change how we write Scala code for the better.

* Material *

Slides: http://plastic-idolatry.com/erik/nescala2018.pdf

* Event * 

Typelevel Summit Boston, March 2018: https://typelevel.org/event/2018-03-summit-boston/

* About Speaker *

Erik Osheim is one of the founders of Typelevel, and maintains several Scala libraries including Cats, Spire, and others. He hacks Scala for a living at Stripe, and is committed to having his cake and eating it too when it comes to functional programming. Besides programming he spends time playing music, drinking tea, and cycling around Providence, Rhode Island.

* Licensing *

This recording is licensed under CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/).