org.pkl.thirdparty.paguro.tuple.package.html Maven / Gradle / Ivy
Show all versions of pkl-tools Show documentation
Immutable, type-safe, heterogeneous containers - ML calls these "records."
ML, Haskell, and Scala use tuples - why not Java?
Actually, tuples are *more* important in Java because Java does not have type aliases.
Instead of type aliases, extend tuples to give them descriptive names.
Consider providing meaningfully named accessor methods.
Doing so is brief, ensures immutability, and provides correct, efficient equals()
,
hashcode()
, and toString()
methods.
When you are experimenting, use tuples to leverage Java's type inference engine in fluent code so that you don't need to specify any types.
When you decide to keep your experiment, extend tuples to give meaningful names to your data types and their fields.
Look at UsageExampleTest.java (the unit test) to see why tuples are so important and flexible.