[Main website]


[1] Y. Zhang and A. C. Myers, “Familia: unifying interfaces, type classes, and family polymorphism,” Proceedings of the ACM on Programming Languages, vol. 1, no. OOPSLA, pp. 1–31, Oct. 2017, doi: 10.1145/3133894.

Inheritance is used as traits, and it does not create a subtype. Only interfaces create a subtype relationship.

It can describe things like C++ concepts, but it seems also rather complex to understand in no-naive examples.

// This interface is like a "concept" because it relates two types `Vertex` and `Edge`.
interface Graph(Vertex, Edge)
extends Hashable(Vertex) {
  Vertex Edge.source();
  Vertex Edge.sink();
  Iterable[Edge] Vertex.outgoingEdges();
  Iterable[Edge] Vertex.incomingEdges();

// NOTE: this class implements a Graph transposing another graph
// and without producing intermediate data structures
class transpose[Vertex, Edge]
for Graph(Vertex, Edge)
where Grap(Vertex, Edge) g {
  Vertex Edge.source() { return this.(g.sink()); }
  Vertex Edge.sink()   { returs this.(g.source()); }
  // ...

TODO compare with Rust approach