Any interest in a Type Disjunction (Union Types) SIP?

Skip to first unread message

Benjamin Jackman

Feb 5, 2014, 11:39:45 PM2/5/14
I was wondering if anyone has interest in or had thoughts on
a Scala compiler & Scala library supported version of Unions Types.

For me, the lack of union types keeps cropping up as source of a lot of boilerplate. 
I am currently on a new project at work where Unions would be quite useful. Right 
now we use a sealed trait + case classes pattern to encode them. This has the nice
property of having the compiler generate exhaustive checks in match expressions.

This Stack Overflow post list several different methods different members of the community have gone
about attacking Scala's lack of native union type:

I understand Scala is intended to be a scala-ble language and enabling users to create powerful
constructs like this on their own is one of the goals of the language. However reading over the Futures SIP got 
me to thinking that part of the motivations for having Futures directly in the standard library was to have a 
consistent version across the Scala ecosystem. I think that motivation could be applied here as well and with 
similar benefits.

I also remember Martin mentioning that union types would eventually be added to the language, but my google-fu
is lacking and I can't dig up the quote. I haven't been keeping up with the mailing list for a while so I am not
sure if this is still the view held by Martin / others in the community.

Benjamin Jackman

Simon Ochsenreither

Feb 6, 2014, 2:15:06 AM2/6/14
Without having any decision-making capabilities, my gut feeling is that union and Intersection types will arrive sooner or later.

They are featured quite prominently in DOT, Scala's "upcoming" type system formalization, so you maybe want to look into that for more information:

Here was an interesting thread on the mailing list, which approached union/intersection types more from a developer's perspective of "what do I want to have out of it?":

Prashant Sharma

Feb 6, 2014, 2:23:31 AM2/6/14
is DOT any close to coming to scala ? I was in an impression, it is still in its initial phase. 

You received this message because you are subscribed to the Google Groups "scala-sips" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit


Lukas Rytz

Feb 6, 2014, 3:15:00 AM2/6/14
DOT is indees in early stages, not close to coming to Scala. It is a research project to explore a new foundation for a Scala-like type system.

Feb 6, 2014, 11:51:14 AM2/6/14
Union and intersection types are the features that would save me the most code/pain.

Suminda Dharmasena

Mar 19, 2014, 1:09:27 PM3/19/14
Biggest selling point in my point of OCaml and F# is Type Unions. 

Type unions will introduce non inheritance based typing hierarchy. E.g.

Tomer Ben David

Dec 1, 2014, 11:40:08 AM12/1/14
definitely, I would love to see support for Union Types! Life are so much
difficult without it!

Ruslan Shevchenko

Dec 1, 2014, 12:31:35 PM12/1/14

Леонид Горшков

Dec 2, 2014, 9:33:31 PM12/2/14
+1. For eeexamle, It can be very useful for fluent builder interfaces for exclude called methods
Reply all
Reply to author
0 new messages