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

380 views
Skip to first unread message

Benjamin Jackman

unread,
Feb 5, 2014, 11:39:45 PM2/5/14
to scala...@googlegroups.com
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

unread,
Feb 6, 2014, 2:15:06 AM2/6/14
to scala...@googlegroups.com
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: https://github.com/namin/dot

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?": https://groups.google.com/d/topic/scala-language/J8LpYDmrOCg/discussion

Prashant Sharma

unread,
Feb 6, 2014, 2:23:31 AM2/6/14
to scala...@googlegroups.com
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 scala-sips+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Prashant

Lukas Rytz

unread,
Feb 6, 2014, 3:15:00 AM2/6/14
to scala...@googlegroups.com
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.

kkli...@gmail.com

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

Suminda Dharmasena

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

Type unions will introduce non inheritance based typing hierarchy. E.g. https://blogs.janestreet.com/a-and-a/.

Tomer Ben David

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

Ruslan Shevchenko

unread,
Dec 1, 2014, 12:31:35 PM12/1/14
to scala...@googlegroups.com, tome...@gmail.com
+1

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

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