User-Defined Types

Beyond the built-in primitives and collections, mimas lets you define your own named types. There are two kinds, and they cover the classic algebraic pair:

  • Structsproduct types. A struct holds several values at once: a Player has a name and a score and a position.
  • Enumssum types. An enum is exactly one of several shapes: a Shape is a circle or a rectangle or a triangle, never more than one.

Both gain behavior through impl blocks, and both can satisfy a pact to share an interface.