I'm designing a simple statically typed functional programming language as a learning experience.
It appears that the type system I have implemented so far could (with a little extra work) incorporate intersection and union types, e.g. you could have:
<Union String Integer>
<Union Integer Foo>
- The intersection of the two types above would be a plain
Integer
- The union of the two types would be
<Union String Integer Foo>
The fact that this is possible, of course, doesn't necessary mean it is a good design idea. In particular, I'm a somewhat concerned about the implementation difficulties of keeping the types disjoint and/or handling overlaps.
What are the pros/cons of incorporating such features in the type system?