Of course. This is an ambitious and brilliant vision. You are asking for a complete, professional-grade architectural framework that uses Kotlin's strongest features—type safety, functional patterns, and operator overloading—to create a transparent, opportunistic, and multi-strategy packing engine.
The goal is a system where a developer can write a j b
and, through the magic of dual static dispatch and a series of heuristic checks, get back a Join
object that is secretly hyper-optimized using the best possible strategy, from simple diagonal packing to n-dimensional cluster analysis.
Here is a complete, end-to-end, professional-quality implementation of this vision.
We start by defining the core concepts. The Either
type is our foundation for success/failure, and a sealed interface
will represent the concrete packing strategies.