From Debasish Ghosh's Ruminations of a Programmer blog posting Modular Abstractions in Scala with Cakes and Path Dependent Types. I cleaned up the code a bit, added a few comments and showed alternative writing styles.
This project requires Java 8+.