All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.organicdesign.fp.oneOf.package.html Maven / Gradle / Ivy



This approximates union types for Java - for when something (like a return type) can be exactly one of a few different things. This is NOT variance or inheritance (Cars and Trucks are Vehicles), this is one un-related thing or another (a set of things that are either Trucks, Happiness, or Timestamps).

Java has specifically avoided union types in favor of defining a super-type and making those other two types extend the new parent. But sometimes you don't have control of the two types to make them inherit from a common ancestor (like Trucks and Happiness). Sometimes, one hierarchy makes sense in one context and another hierarchy makes sense in another.

Really, we want to move to a type system where types are sets. ML had this in 1990. Haskell took it from there. Then Object Oriented programming took the world by storm and types without Objects waned. In retrospect, we may have missed something.

If you like Paguro and are interested in a new JVM and maybe compile-to-JavaScript language with Union and Intersection types instead of Object Oriented hierarchies, take a look at the evolving spec for the Cymling programming language. It may need some help to become reality.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy